A 12-year-old boy, who is the youngest to appear in court in relation to this summer's riots, has been handed a 12-month referral order.
The boy, who cannot be named for legal reasons, pleaded guilty to violent disorder last month in relation to the unrest on 30 July in Southport.
Liverpool Youth Court heard the youngster threw two stones at police officers, the day after a stabbing attack in the town in which three girls were killed.
As well as the referral order, the boy will be subject to a curfew between 21:00 and 07:00 each night for three months.
The court heard the boy was said to have gone to the scene outside the town's mosque because he was "curious" after seeing a fire.
District Judge Wendy Lloyd told the boy "it was an angry mob and you chose to be a part of it".
She added: "It was a really horrible situation and you made it all the more horrible by joining in and throwing stones."
A referral order is a sentence available to the courts when dealing with young people below the age of 18 who have admitted an offence.
It requires them to take part in a rehabilitation programme aimed at preventing them from offending in the future.
'Knows he acted foolishly'
A statement from the chairman of the mosque in Southport, which was targeted in the disorder, was read out in court.
Imam Ibrahim Hussein said inside the mosque, he, three worshippers and some men who said they had been sent by the Home Office to act as security for the mosque, had all armed themselves with metal poles in case they were attacked.
"I believed they would kill us," he said.
He said he could see about 1,000 people outside and they had decided if rioters broke into the mosque they would all lock themselves in his office.
"I could see fire out of every window," he said.
- Rioter's mum to pay compensation after Ibiza trip
- Judge tells of 'unpleasant threats' after riot sentencing
- Who are the rioters and what jail sentences have they received?
He thought at one point, "if we don't get killed by the crowd we're going to die from smoke inhalation".
Despite all of this, he continued to lead prayers in the mosque, adding: "I went ahead with prayers as normal, and ignored the missiles."
Defence lawyer Heather Toohey said the boy was not seen to be involved in any racist chanting and said he had handed himself in at a police station and "asked me to advance his deepest regret and sympathies to the people of Southport".
"He knows he acted foolishly, he knows he acted out of stupidity," she added.
District Judge Lloyd told the boy it was "good" he handed himself in, adding: "I'm told you didn't think about what you were doing when you joined that mob but there wasn't really much to think about."
She told the hearing he had a "complicated and in many ways a sad young life".
She said: "School has not gone well for you and you're now living with your dad and at 12 you've already had alcohol issues which I find extremely concerning.
"What you did that night was very wrong. It really was a horrible situation and made it all the more horrible by joining in and throwing stones."
Widespread disorder broke out in towns and cities across the UK in July and August following the Southport knife attack in which three young girls were killed.