Chinese President Xi Jinping has sworn in Hong Kong's new leader with a stark warning that Beijing won't tolerate any challenge to its authority in the divided city as it marked the 20th anniversary of its return from Britain to China.
Police blocked roads, preventing pro-democracy protesters from getting to the harbour-front venue close to where the last colonial governor, Chris Patten, tearfully handed back Hong Kong to China in the pouring rain in 1997.
"Any attempt to endanger China's sovereignty and security, challenge the power of the central government ... or use Hong Kong to carry out infiltration and sabotage activities against the mainland is an act that crosses the red line and is absolutely impermissible," Xi said.
He also referred to the "humiliation and sorrow" China suffered during the first Opium War in the early 1840s that led to the ceding of Hong Kong to the British.
Hong Kong has been racked by demands for full democracy and, more recently, by calls by some pockets of protesters for independence, a subject that is anathema to Beijing.
Xi's words, in a 30-minute speech, were his strongest yet to the city amid concerns over what some perceive as increased meddling by Beijing, illustrated in recent years by the abduction by mainland agents of some Hong Kong booksellers and Beijing's efforts in disqualifying two pro-independence lawmakers elected to the city legislature.
"It's a more frank and pointed way of dealing with the problems (in Hong Kong)," said former senior Hong Kong government adviser Lau Siu-kai on Hong Kong's Cable Television.
"The central government's power hasn't been sufficiently respected ... they're concerned about this."
The tightly choreographed visit was full of pro-China rhetoric amid a virtually unprecedented security lockdown.
Xi did not make contact with the people in the street or with any pro-democracy voices, forgoing an opportunity to lower the political heat.
Under Hong Kong's mini-constitution, the Basic Law, the financial hub is guaranteed wide-ranging autonomy for "at least 50 years" after 1997 under a "one country, two systems" formula praised by Xi.
It also specifies universal suffrage as an eventual goal.
But Beijing's refusal to grant full democracy triggered nearly three months of street protests in 2014 that at times erupted into violent clashes and posed one of the greatest populist challenges to Beijing in decades.
'Most urgent' protest in years
Thousands gathered in the afternoon in a sprawling park named after Britain's Queen Victoria, demanding Xi allow universal suffrage.
"This protest is the most urgent in the past 20 years," said lawmaker Eddie Chu, as some demonstrators marched with yellow umbrellas, a symbol of democratic activism in the city, and held aloft banners denouncing China's Communist "one party rule".
Others criticised China's Foreign Ministry which on Friday said the "Joint Declaration" with Britain over Hong Kong, a treaty laying the blueprint over how the city would be ruled after 1997, "no longer has any practical significance".
Xi, dressed in a dark suit and striped red tie, in the morning addressed a packed hall of mostly pro-Beijing establishment figures, after swearing in Hong Kong's first female leader, Carrie Lam, who was strongly backed by China.
Lam, speaking in Mandarin instead of the Cantonese dialect widely used in Hong Kong and southern China, said she wanted to create a harmonious society and bring down astronomical housing prices that have also sown social discord.
Lam also pledged to take firm legal action against those who "undermine" China's sovereignty, security and development interests.
Xi hinted that the central government was in favour of Hong Kong introducing "national security" legislation, a controversial issue that brought nearly half a million people to the streets in protest in 2003 and ultimately forced former leader Tung Chee-hwa to step down.
A small group of pro-democracy activists near the venue were roughed up by a group of men who smashed up some props in ugly scuffles while surrounded by more than 100 police.
Nine democracy protesters, including Joshua Wong and lawmaker "long hair" Leung Kwok-hung, were bundled into police vans while several pro-China groups remained, cheering loudly and waving red China flags.
The activists, in a later statement, said the assailants had been "pro-Beijing triad members".
Other protesters unfurled a massive yellow banner, with the words "I want real universal suffrage", on the waterfront of Hong Kong's Victoria Harbour, but were later taken away by police.