Hong Kong police fired water cannon and tear gas and arrested more than 300 people on Wednesday as protesters took to the streets in defiance of sweeping security legislation introduced by China to snuff out dissent.
Beijing unveiled the details of the much-anticipated law late on Tuesday after weeks of uncertainty, pushing China's freest city and one of the world's most glittering financial hubs on to a more authoritarian path.
As thousands of protesters gathered for an annual rally marking the anniversary of the former British colony's handover to China in 1997, riot police used pepper spray and fired pellets as they made arrests after crowds spilled into the streets chanting "resist till the end" and "Hong Kong independence".
"I'm scared of going to jail but for justice I have to come out today, I have to stand up," said one 35-year-old man who gave his name as Seth.
Police said they had made more than 300 arrests for illegal assembly and other offences, with nine involving violations of the new law.
The law punishes crimes of secession, subversion, terrorism and collusion with foreign forces with up to life in prison, will see mainland security agencies in Hong Kong for the first time and allows extradition to the mainland for trial.
China's parliament adopted the law in response to protests last year triggered by fears that Beijing was stifling the city's freedoms, guaranteed by a "one country, two systems" formula agreed when it returned to Chinese rule. Beijing denies the accusation.
Hong Kong police cited the law in confronting protesters.
"You are displaying flags or banners/chanting slogans/or conducting yourselves with an intent such as secession or subversion, which may constitute offences under the ... national security law," police said in a message displayed on a purple banner.
Authorities in Beijing and Hong Kong have repeatedly said the legislation is aimed at a few "troublemakers" and will not affect rights and freedoms, nor investors' interests.
But critics fear it will end the pro-democracy opposition and crush freedoms, including an independent legal system and right to protest, that are seen as key to Hong Kong's success as a financial centre.
US Secretary of State Mike Pompeo said the new law was an affront to all nations and Washington would continue to implement President Donald Trump's directive to end the territory's special status.
Britain said it would stand by its word and offer all those in Hong Kong with British National Overseas status a "bespoke" immigration route.
British Foreign Secretary Dominic Raab described Wednesday's protests as heartbreaking and reprimanded HSBC and other banks for supporting the new law, saying the rights of Hong Kong should not be sacrificed for bankers' bonuses.
Britain and Canada also updated their travel advisories for Hong Kong, saying there was an increased risk of detention.
A former employee of the British consulate in Hong Kong, Simon Cheng, said he had been granted political asylum by the British government after being beaten by Chinese secret police last year in mainland China during 15 days of detention.
In a post on Facebook after the enactment of the national security law, he said he hoped other Hong Kong people would be offered protection by Britain.
Police fired water cannon to try to disperse the protesters. A game of cat and mouse reminiscent of last year's often violent demonstrations followed, with protesters blocking roads before running away from riot police charging with batons, only to re-emerge elsewhere.
Police posted pictures on Twitter of an officer with a bleeding arm saying he was stabbed by "rioters holding sharp objects". The suspects fled while bystanders offered no help, police said.
On July 1 last year, hundreds of protesters stormed and vandalised the city's legislature to protest against a bill that would have allowed extraditions to mainland China.
Those protests evolved into anti-China demonstrations and calls for democracy, paralysing parts of the city and paving the way for Beijing's new law.
In Beijing, Zhang Xiaoming, executive deputy director of Beijing's Hong Kong and Macau Affairs Office, told reporters suspects arrested by a new Beijing-run security office could be tried on the mainland.
He said the new office abided by Chinese law and that Hong Kong's legal system could not be expected to implement the laws of the mainland. Article 55 of the law states that Beijing's security office in Hong Kong could exercise jurisdiction over "complex" or "serious" cases.
"The law is a birthday gift to (Hong Kong) and will show its precious value in the future," Zhang said, adding the law would not be applied retroactively.
Speaking at a flag-raising ceremony to mark the handover, the city's Beijing-backed leader, Carrie Lam, said the law was the most important development since 1997.
"It is also an inevitable and prompt decision to restore stability," Lam said at the harbour-front venue where the last colonial governor, Chris Patten, a staunch critic of the security law, tearfully handed back Hong Kong to China.
Some pro-Beijing officials and political commentators say the law is aimed at sealing Hong Kong's "second return" to the motherland after the first failed to bring residents to heel.
Luo Huining, the head of Beijing's top representative office in Hong Kong, said at the ceremony the law was a "common aspiration" of Hong Kong citizens.
Some pro-democracy activists gave up membership of their groups just before the law came into force on Tuesday, though they called for the campaign to carry on from abroad.
"I saw this morning there are celebrations for Hong Kong's handover, but to me it is a funeral, a funeral for 'one country two systems'," said pro-democracy lawmaker Kwok Ka-ki.