Chinese President Xi Jinping has officiated the swearing-in ceremony of Hong Kong’s new leader as the city marked the 25th anniversary of its return to Chinese rule after being pulled in recent years under much tighter Communist Party control.

John Lee, a former security official who oversaw the crackdown on dissent in the city since 2019 pro-democracy protests, pledged to uphold the city’s mini-constitution, the Basic Law, and bear allegiance to Hong Kong. He also pledged to be accountable to the central government in Beijing.

His inauguration followed a morning flag-raising ceremony attended by Mr Lee, outgoing city leader Carrie Lam and several hundred other people. Mr Xi, who is making his first trip off the mainland in two-and-a-half years, was not present at the ceremony.

On his arrival Thursday, Xi told well-wishers that Hong Kong has overcome many challenges over the years and had been “reborn from the ashes” with “vigorous vitality,” in an apparent allusion to the 2019 pro-democracy protests, which were followed by a sweeping crackdown on dissent that has transformed the economic hub once known for its political and civic freedoms.

Hong KongTroops march at the flag raising ceremony at the Golden Bauhinia Square to mark the 25th anniversary of Hong Kong’s return to Chinese rule (Magnum Chan, Pool/AP)

The flag-raising ceremony was held amid strong winds, and police officers carrying the Chinese and Hong Kong flags marched into the Golden Bauhinia Square for the ceremony with the Chinese goose-stepping style, replacing a British-style march. Guests stood at attention as the Chinese national anthem was played.

Mr Xi last visited Hong Kong in 2017 for the July 1 celebrations, during which he warned that there would be no tolerance for any activities seen as threatening China’s sovereignty and stability.

The months of pro-democracy protests in 2019 were seen by China’s ruling Communist Party as just such a threat, and Mr Xi in remarks on Thursday evening praised Lam for ending chaos that had gripped the city and for ensuring that only “patriots” would rule Hong Kong.

Since the protests, Beijing and Hong Kong authorities drafted a national security law that was then used to arrest scores of activists, media figures and democracy supporters; introduced a more patriotic curriculum in schools; and revamped election laws to keep opposition politicians out of the city’s Legislature.

The changes have all but eliminated dissenting voices in the city and have driven many to leave.