"Thugs" were to blame for the violence that saw 39 police officers injured in Southport, the town's MP has said.
Unrest broke out in the Merseyside town hours after a vigil to remember the victims of Monday's knife attack at a dance school in which three young girls were killed.
Officers were pelted with bricks, a police van was set on fire, and eight officers were seriously hurt, Merseyside Police said.
MP Patrick Hurley described the violence - close to a mosque - as "horrific".
Hurley told BBC's Radio 4 Today programme that the "riot" was "led by people from outside the town".
Police said the violence was believed to have involved English Defence League supporters.
Hurley condemned "thugs who had got the train in" who were using the "deaths of three little kiddies for their own political purposes".
On Tuesday, Merseyside Police named the three girls who were killed at a Taylor Swift-themed dance workshop at the Hart Space studio in Hart Street.
They were six-year-old Bebe King, Elsie Dot Stancombe, seven, and Alice Dasilva Aguiar, nine.
At about 6pm local time, a peaceful vigil was held outside the Atkinson gallery in Lord Street, with more than 1000 people estimated to have attended.
Throughout the day, though, there had been rumours circulating online of a planned demonstration near to a mosque on St Luke's Road.
At about 19:45, demonstrators began to gather and engaged in a stand-off with police officers.
As the disorder escalated, officers donned protective gear and used riot shields to defend themselves from bricks, wheelie bins and other objects being hurled towards them.
A police vehicle was also set on fire.
Hurley said it was "reprehensible" that police officers who had, the day before been attending to injured victims, were finding themselves "being pelted with bricks by these thugs".
The MP said they had "hijacked the grief" of the town and families.
He said: "These people are utterly disrespecting the families of the dead and injured and totally disrespecting the town."
In total, 27 officers were taken to hospital, and 12 were treated and discharged at the scene, the ambulance service said.
A 24-hour Section 60 Order has been put in place, giving police extra stop and search powers.
A Section 34 Order has also been introduced, allowing police to direct people who are engaging in antisocial behaviour or are "likely to become involved in such behaviour" away from the area.
Merseyside Police said extra officers would remain in the area "to provide a visible presence and reassure communities".
Assistant Chief Constable Alex Goss said it was "sickening" that this was happening within a "devastated" community.
He said the force has faced "serious violence" and was "so proud to have witnessed off-duty officers parade back on duty to support their colleagues who had displayed such courage whilst under constant and sustained attack."
ACC Goss also thanked officers from Greater Manchester Police, Cheshire Police, Lancashire Police and North Wales Police for providing mutual aid and support.
He added the disorder involved many people "who do not live in the Merseyside area or care about the people of Merseyside".
"Sadly, offenders have destroyed garden walls so they could use the bricks to attack our officers and have set cars belonging to the public on fire, and damaged cars parked in the Mosque car park," he said.
"This is no way to treat a community, least of all a community that is still reeling from the events of Monday."
'Fears for safety'
A 17-year-old boy was arrested on suspicion of murder and attempted murder after Monday's attack.
ACC Goss said: "There has been much speculation and hypothesis around the status of a 17-year-old male who is currently in police custody, and some individuals are using this to bring violence and disorder to our streets.
"We have already said that the person arrested was born in the UK, and speculation helps nobody at this time."
PM Sir Keir Starmer said on X that the people of Southport were "reeling" after the "horror inflicted on them yesterday".
He said that those who had "hijacked the vigil for the victims with violence and thuggery" had insulted the community and would "feel the full force of the law".
Families living nearby told the BBC they feared for their safety as stones flew past and police officers rushed to put on riot gear and pick up shields.
"I can't believe this is happening in Southport," one young woman shouted from the front of her car as she tried to drive her young daughter away.
The disorder began after hundreds of people gathered near a local mosque attacking the front of it, throwing bricks, bottles, fireworks and rocks, many with hoods up and scarves hiding their faces.
Merseyside Police said those behind the violence had been fired up by social media posts which incorrectly suggested an Islamist link to Monday's stabbings.
The Home Secretary Yvette Cooper had earlier warned about disinformation linked to the attack.
The suspect has no known links to Islam.
Cooper later said it was "appalling" that police officers in Southport were facing attacks from "thugs on the streets who have no respect for a grieving community".
"I think everyone should be showing some respect for the community that is grieving and also for the police who are pursuing an urgent criminal investigation now, and who showed such heroism and bravery yesterday in the face of these horrific attacks," she said.
In a statement on X, Merseyside Police and Crime Commissioner Emily Spurrell also said she was "absolutely appalled by the disgraceful scenes of violence".
"This is a community which has faced unimaginable tragedy, and it is grieving.
"Such behaviour is abhorrent and only causes further harm and suffering," she added.
Merseyside Police Chief Constable Serena Kennedy posted on X that more than 1000 residents from Southport had come together at the vigil to remember the little girls who had died, those who were still critical in hospital and all those who witnessed and were traumatised by the events from yesterday.
"This is where all of our focus should be," she said.