Hong Kong is making final preparations and unprecedented security arrangements for President Xi Jinping’s visit, which has been confirmed for Thursday to Saturday, to mark the 20th anniversary of the city’s handover from British to Chinese rule and swear in a new administration.

The president would also “inspect” the city, the official Xinhua news agency announced on Sunday, confirming a Postreport on Friday that Xi would visit for the first time since becoming China’s leader in 2013.

On Friday, he will inspect the local garrison of the People’s Liberation Army, as commander of China’s armed forces, before attending functions at the convention centre in Wan Chai.

Both incoming and exiting chief executives expressed their “deepest gratitude” to Xi on Sunday for the coming visit. Leung said it showed the importance Beijing attached to Hong Kong, while his incoming successor noted Beijing’s support for the city since the handover.

Lawmaker Starry Lee Wai-king, who heads the city’s biggest pro-establishment party, echoed their sentiments, urging different political groups to grasp the opportunity and meet the president.

Ahead of the Xinhua announcement, security minister Lai Tung-kwok said the government would remain vigilant against the threat of terror attacks, and that the city’s police force had enough staff to handle any emergencies during the president’s visit. He said the authorities were particularly concerned about “lone wolf” terrorists who have been responsible for attacks overseas.

“Law and order in Hong Kong is well maintained, but that does not mean we do not need to take corresponding actions to get prepared,” Lai said, adding that police had been closely monitoring terrorist incidents around the world.

Activists are also gearing up to mark Xi’s visit with protests. Democrat Au Nok-hin, convenor of the Civil Human Rights Front, said the group was planning another march on top of the annual July 1 rally to ensure the president heard their voices.

Xi last visited Hong Kong in 2008 as vice-president, but he has a long history of contact with the city well before that.