The Chinese president has sworn in the new leader of Hong Kong, Carrie Lam, as the territory marks 20 years since its handover to China from Britain.
But clashes have taken place between pro-democracy and pro-Beijing demonstrators close to the site, with several arrests made.
In a speech, Mr Xi said Hong Kong now enjoyed more freedom than ever before.
It was his first visit to the city since becoming leader in 2013 and comes three years after mass pro-democracy rallies crippled parts of the territory for months.
The pro-democracy party, Demosisto, said police had arrested five of its members, and four members from the League of Social Democrats.
Among those said by the group to have been arrested was Joshua Wong, the leader of the so-called umbrella protest movement.
Meanwhile, Mr Xi has overseen the swearing in of the newly-elected chief executive of the territory, Carrie Lam, along with the rest of her cabinet. She is Hong Kong’s first female leader.
In a speech on Saturday the Chinese president said Hong Kong now enjoyed more freedom than ever before, but warned against “impermissible” challenges to Beijing’s authority over the city.
“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,” he said.
It followed a ceremony in which the flags of China and Hong Kong were raised alongside one another to mark the 20-year anniversary of the city’s handover of British rule.
Helicopters flew overhead as onlookers cheered at the ceremony in Golden Bauhinia Square, central Hong Kong.
On Friday, an official protest zone near the convention centre where Mr Xi was guest of honour at an anniversary banquet and variety performance was heavily patrolled, as demonstrators gathered chanting “end one-party dictatorship”.
There is growing concern that the Chinese central government is undermining Hong Kong’s more politically liberal traditions, despite its promise to give it a high degree of autonomy under the “one country, two systems” principle.
Democracy campaigners clashed with pro-Beijing supporters near the venue, with police separating the two sides.
Among the pro-democracy activists was Mr Wong, who earlier told demonstrators that the only person responsible for “causing a public nuisance” was “Xi Jinping”.
He and 25 other activists were arrested on Wednesday for “breaking the ‘public nuisance’ law” after climbing into a golden sculpture of a bauhinia flower, Hong Kong’s emblem.
The sculpture, which sits by the city’s harbour front, was a gift from China and an iconic landmark symbolising the handover.
The demonstrators, who were demanding greater political freedoms, also called for the release of terminally ill Chinese dissident Liu Xiaobo.
Mr Wong was released on Friday morning, the political party Demosisto, founded by him and legislator Nathan Law, said in a tweet.
Police said in a statement the activists had been released on bail and must report back to police in September. They have not been charged.
Their protest was the second one this week at the monument – activists had earlier draped a large black flag over the sculpture and were stopped by police.
President Xi earlier on Friday inspected troops at a local garrison as part of what was described as the largest military parade in the city since its handover to China in 1997, Reuters news agency reports.
Mr Xi gave a short speech on Thursday after his arrival where he pledged Beijing’s support for Hong Kong, and later met with the city’s outgoing leader Leung Chun-ying and other officials.
Join GhanaStar.com to receive daily email alerts of breaking news in Ghana. GhanaStar.com is your source for all Ghana News. Get the latest Ghana news, breaking news, sports, politics, entertainment and more about Ghana, Africa and beyond.
(Via: CitiFM Online Ghana)