His three-day trip to celebrate 20 years since Hong Kong was handed back to China by Britain, culminated Saturday in a 30-minute speech warning that any challenge to Beijing's control over the city crossed a "red line".
That was seen as a salvo against a new wave of activists calling for self-determination or independence for semi-autonomous Hong Kong, concepts intolerable to Beijing.
Throughout the televised address, Xi played up Hong Kong's role in upholding China's national security and sovereignty, casting it as a potential breeding ground for instability that must be reined in.
It comes after major political turbulence in recent years which saw mass rallies calling for democratic reform bring parts of the city to a standstill for months in 2014.
Since then, a "localist" movement has emerged promoting Hong Kong's own separate identity as fewer young people see themselves as "Chinese". Some in that camp want a complete split from the mainland.
The address laid out a "very strong warning" against dissenters, said Jean-Pierre Cabestan, a political science professor at Hong Kong Baptist University.
"Xi's acting as a schoolmaster, warning there will be consequences if they misbehave," he added.
Xi also called on authorities to "enhance" education to raise awareness of China's national history and culture, alluding to the need to bring young people back into the fold.
By putting national security and education front and centre, Xi is pushing Hong Kong's new Beijing-friendly leader Carrie Lam to revisit two potentially explosive catalysts for social and political unrest.
The last attempt to implement a compulsory patriotic curriculum was shelved in 2012 after huge rallies by parents, teachers and students who feared it was Beijing brainwashing. Those protests were led by a then 15-year-old Joshua Wong, now an internationally known pro-democracy campaigner.
A proposed anti-subversion national security law also triggered massive demonstrations in 2003 over concerns it would lead to suppression of rights and freedoms. It has never been implemented.
"If Carrie Lam does what Xi Jinping said, which is to relaunch the national education campaign and to draft a national security law, she's going to antagonise a lot of Hong Kong people," said Cabestan.
Xi appeared relaxed, almost disinterested at times, during a visit which included presiding over Hong Kong's biggest military parade since the 1997 handover.
But his demeanour did not reflect an absence of purpose. The South China Morning Post described his strategy as "speak softly but carry a big stick", a proverb made famous by United States President Theodore Roosevelt to describe his approach to foreign policy.
Xi avowed his commitment to Hong Kong's semi-autonomous status as concerns deepen that China is increasingly interfering in the city's affairs.
Yet Beijing's foreign ministry on Friday declared the document signed by Britain and China which initiated the handover was "no longer relevant".
The Sino-British Joint Declaration gave Hong Kong rights unseen on the mainland through a "one country, two systems" agreement, lasting 50 years.
Xi said there must be a better understanding and implementation of the semi-autonomous set-up, which he likened to a tree with deep roots.
Its raison d'etre was to "uphold national unity", he said.
"The message is quite clear that one country towers over two systems," said Willy Lam, a politics expert at the Chinese University of Hong Kong.
"He's asking Hong Kong people to obey instructions because the sovereign power overrides everything," Lam added.
Xi's visit laid bare again the divisions in Hong Kong society between those who are pro-China and those who fear its tightening grip.
There were sporadic protests and arrests during an unprecedented security lockdown as well as confrontations between democracy activists and pro-Beijing protesters -- accused by opponents of being hired thugs.
Flag-waving fans filled public squares near where Xi was staying for three days of music, dance and celebrations.
Those who welcomed the visit said the stark warnings Xi issued were to be expected.
"There's definitely a bottom line for every country," said legislator Felix Chung, head of the pro-establishment Liberal Party.
"I think Hong Kong people thought the visit was very positive."
Others painted a different picture.
Pro-democracy lawmaker Claudia Mo said the lavish official celebrations reminded her of North Korea or the Cultural Revolution -- a time of mass political purges in China.
"He wanted to instill fear and respect, or respect out of fear, from Hong Kong people," Mo told AFP.
"But instead I think a larger portion felt resentment."
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)