Radio 1 has been rebuked by watchdog Ofcom for breaching the broadcasting code with swearing during its Big Weekend.

Listeners heard Lily Allen and Ed Sheeran swear during the live broadcast of the music event in Glasgow.

Sheezus singer Allen said f*** six times, between around 5.30pm and 6pm, while Sheeran used the word f****** just before 7pm.

On-air presenter Scott Mills had warned listeners that the singers' sets could contain "strong language" during the broadcast in May.

The BBC said that it had undertaken a "comprehensive risk assessment" and that singers were told not to swear.

It said that on the "relatively rare" occasions that there was swearing, there was an immediate apology.

The BBC said that it had considered cutting away from Allen's set twice during her performance, but a senior producer decided to continue because apologies had been given and it was believed that few children would be listening.

But it said that in retrospect, Radio 1 should have stopped broadcasting live during Allen's set.

Ofcom said that the offensive language was broadcast at a time when children were likely to be listening.

It pointed to a previous incident, in 2011, from the same event, when offensive language was used by the Black Eyed Peas.

On that occasion, the issue was resolved but broadcasters were warned that they should take steps to avoid strong language during live performances.

Ofcom said that as "Radio 1 was both the event promoter and broadcaster" of Big Weekend, it had a lot of control over the scheduling of performances.

As Allen was known to use strong language "it was reasonably predictable that her set could contain the most offensive language", it said.

"The BBC also had the option of cutting away from Lily Allen's set after the first occasion when she used the most offensive language but failed to do so," it added.

Finding the broadcast in breach, Ofcom concluded: "In light of Ofcom's decision in 2011, we considered that the BBC should have been more aware of this risk when broadcasting the same event in 2014.

"We are concerned that it did not take more measures both before and during the broadcast to ensure compliance ... taking into account that the event was to be broadcast at a time when children were particularly likely to be listening."

Allen sang 11 songs during the broadcast and swore in the lyrics six times during three of them.

The BBC Trust - the corporation's governing body - called the broadcast a "serious breach" of editorial guidelines on harm and offence.

The BBC had seen Allen's set list and was alert to those songs which could feature offensive lyrics.

The star, alongside Sheeran, was considered of "Category B" or "Medium Risk".

The Trust criticised the corporation for not having "sought assurances that 'radio edit' versions (of songs) would be performed".

It said the BBC "appeared to rely on the artists judging what was acceptable".

Trustees were "particularly concerned" that the breach had come after "several similar incidents", including the broadcast of Live 8 in 2005, Live Earth in 2007 and Radio 1's Big Weekend in 2011.

"The BBC had an even greater degree of responsibility in regard to Radio 1's Big Weekend because it had editorial control in advance that it would not necessarily have over other events," the Trust said.

It added that Big Weekend was "not a new dilemma facing Radio 1 executives - the festival has been running for more than a decade".

The BBC has been developing a new policy, which includes warning artists that live coverage could end if they use strong language.

Some listeners also complained about the repeated warnings and apologies broadcast during the event.

A BBC spokeswoman said: "We note the findings of Ofcom and the Trust. We have examined our procedures and tightened them accordingly."