Hong Kong riot police swooped on pro-democracy protesters trying to flee a university they had set ablaze Monday, in one of the most violent confrontations seen in nearly six months of unrest.

Hundreds of demonstrators clashed throughout the day with police who had threatened to use deadly force, as protests also flared in other parts of the city.

Monday’s events were part of a new phase of violence that began last week and has led to chaos throughout the city of 7.5 million people, with schools closed, train lines disrupted and major roads blocked by barricades.

China has refused to budge on any of the protesters’ demands and warned it will not tolerate dissent.

Chinese soldiers briefly appearing on Hong Kong’s streets over the weekend supposedly to clean up debris fueled concerns it could intervene militarily.

On Monday police tried to dislodge several hundred hard-core protesters who had occupied Hong Kong Polytechnic University over the weekend.

Overnight the mainly black-clad youngsters set fire to the university’s main entrance as they repelled an attempted police incursion. Daylight saw no let up, with clashes every time activists emerged from the campus. Hails of tear gas greeted attempts to break out, with activists forced to retreat or trying to find holes in a police cordon.

Police made dozens of arrests — sometimes beating people with batons as they held them on the ground. Officers crowded around those who fell during charges, and could occasionally be seen kicking helpless protesters.

Also on Monday, a Hong Kong court found that the government’s controversial mask ban is unconstitutional, delivering a fresh legal blow to an administration that is struggling to contain increasingly violent protests.

The High Court ruling came in response to a challenge filed by the city’s opposition lawmakers. Chief Executive Carrie Lam imposed the ban last month by invoking colonial-era emergency powers for the first time in more than a half century.

“The government should fully respect the decision,” Alvin Yeung, an opposition lawmaker, said of the court’s ruling.

Lam’s Oct. 4 move to invoke the Emergency Regulations Ordinance, which was last used during riots in 1967, sparked protesters’ fury and prompted a fresh wave demonstrations. Some protesters have deliberately flouted the ban by wearing masks and costumes at rallies and police have arrested hundreds over alleged violations of the regulation.

The regulation called for jail sentences of up to one year for violators.

The judges said the measure “exceeds what is reasonably necessary to achieve the aim of law enforcement, investigation and prosecution of violent protesters even in the prevailing turbulent circumstances in Hong Kong, and that it fails to strike a reasonable balance between the societal benefits promoted and the inroads made into the protected rights.”

They also ruled the ban was disproportionate due to its “remarkable width” and that there “is practically no limit on the circumstances in which the power under that section can be exercised by a police officer.”Even by recent standards, the last few days have stood out as particularly violent, with one police officer hit in the leg by an arrow, and an armored police vehicle torched.

Officers fired live rounds on Monday, though said they did not think anyone had been hit.

Police declared events at the university a “riot” — rioting is punishable by up to 10 years in jail.

“I hereby warn rioters not to use petrol bombs, arrows, cars or any deadly weapons to attack police officers,” a force spokesman said. “If they continue such dangerous actions, we would have no choice but to use the minimum force necessary, including live rounds, to fire back.”

Hong Kong police routinely carry sidearms, but until now they have only used them in isolated incidents during running street clashes. Three people have been shot, none of them fatally.

They have largely relied on tear gas, water cannons and rubber bullets, but the new warning suggests a more proactive use of live rounds.

Fear gripped protesters inside the campus — whose occupation is a twist in tactics by a leaderless movement so far defined by its fluid nature.

One 19-year-old, who gave her name as “K,” said there was desperation among those who remained.

“Some people were crying badly, some were furious, some agonising, because they felt hopeless as we were left no way out of the campus.

“We don’t know when the police will storm in.”

Protests erupted in several other parts of peninsula Hong Kong, with makeshift barricades across normally bustling shopping streets, the road surfaces strewn with bricks to hamper vehicles.

Police fired tear gas at groups who had gathered in the Tsim Sha Tsui and Jordan areas, where they also made a number of arrests.

The unrest has rocked previously stable Hong Kong, tipping the international financial hub into recession and frightening off tourists.

What began as a series of huge, peaceful demonstrations against a now-shelved bill to allow extradition to the Chinese mainland has morphed into calls for democracy and an inquiry into police behavior.

Violence has worsened this month, with two men killed in separate incidents.

Demonstrators last week engineered a “Blossom Everywhere” campaign of blockades and vandalism, which shut down sections of Hong Kong’s transport network and closed schools and shopping malls.

In his most strident comments on the crisis, Chinese President Xi Jinping said it threatened the “one country, two systems” model under which Hong Kong has been ruled since the 1997 handover from Britain.

On Saturday, dozens of soldiers from the Chinese People’s Liberation Army briefly left their Hong Kong barracks to help clean the streets.

It was a rare and symbolic operation, as the troops are normally confined to barracks and are meant to be only called out in a time of emergency.

Chinese defense ministry spokesman Wu Qian on Monday defended the operation, and repeated warnings from Beijing that the military had the ability to quell the unrest.

“Ending violence and restoring order is the most pressing task we have in Hong Kong,” Wu said.