President Xi Jinping visited Hong Kong to attend a ceremony marking the 25th anniversary of its transfer to Chinese rule, his first trip outside the mainland since the pandemic began in early 2020, state-run media reported Thursday.

The anniversary is scheduled to be commemorated on Friday, with foreign affairs experts saying the former British colony's rights and freedoms, guaranteed as part of the 1997 handover, continue to diminish with Beijing tightening its grip on the semiautonomous Chinese city.

Chinese President Xi Jinping delivers a speech in Hong Kong on June 30, 2022. (Photo courtesy of the Hong Kong government)(Kyodo)

Xi had not left mainland China since he traveled to Myanmar in January 2020 as Beijing acknowledged the rapid spread of the novel coronavirus.

The official Xinhua News Agency said the Chinese president will also take part in an event on Friday for the inauguration of John Lee, Hong Kong's former security chief, as the city's new leader, replacing Carrie Lam.

Lee, known as a staunch supporter of cracking down on pro-democracy activists, has vowed to maintain social order in the special administrative region based on a national security law enacted by Beijing in 2020.

His five-year term will begin at the halfway point of Beijing's "one country, two systems" policy for Hong Kong that was set to last for 50 years until 2047.

In recent years, Beijing has been wielding a heavier hand with Hong Kong after large-scale protests, sparked by a since-withdrawn bill that would have allowed extraditions to the mainland, morphed into a pro-democracy movement in 2019.