China's "one country two systems" model of ruling Hong Kong has worked in protecting the city and must continue long term, says Xi Jinping.
The Chinese leader mounted a stern defence of the political system in a speech in Hong Kong, following recent international criticism.
It is under tight security as it hosts Mr Xi, who is on his first trip outside of the mainland in two years.
Under "one country two systems", Hong Kong is supposed to be governed in a way that gives it a high degree of autonomy and protects freedom of speech and assembly, and other rights not found in mainland China.
But in recent years China has been criticised for increasing its control of Hong Kong and enacting laws and reforms that stifle free speech and dissent.
The "one, country two systems" principle arose out of an agreement between Britain and China and is enshrined in law in Hong Kong. The protections run out in 2047, a deadline which many in Hong Kong have long been worried about.
But on Friday Mr Xi said it "must be adhered to over the long run" - the clearest sign yet that China intends to preserve the political model, which critics say has already been compromised to suit Beijing.
"'One country two systems' has been tested and proved time and again, and there is no reason to change such a good system," he said, to applause from the audience comprising mostly of the city's pro-Beijing elite.
He added the system had the "unanimous endorsement" of residents along with "widespread approval" by the international community, and that Hong Kong's "true democracy began" when it returned to China.
But over the years Hong Kong has seen huge protests and many, including Western countries, have criticised Beijing's growing interference in the city.
In 2020, China introduced a controversial national security law that has clamped down on free speech and dissent in Hong Kong. This prompted Britain to accuse China of violating the "one country two systems" principle and their agreement.
"We're not giving up on Hong Kong," UK Prime Minister Boris Johnson said on Friday.
"Twenty-five years ago we made a promise to the territory and its people and we intend to keep it, doing all we can to hold China to its commitments so that Hong Kong is once again run by the people of Hong Kong, for the people of Hong Kong."
China's recent electoral reforms designed to ensure only "patriots" can run for office in Hong Kong have also been heavily criticised.
But Mr Xi strongly defended this move on Friday, saying that it was "essential for safeguarding the long-term stability and security of Hong Kong" and that "at no time should this principle be allowed to be compromised".
"No people in any country or region in the world would ever allow political power to fall into the hands of forces or individuals who do not love, or would even sell out or betray, their own country," he said.
At the same event, Mr Xi also formally appointed John Lee, a former security chief known for his tough pro-Beijing views, as the new chief executive of Hong Kong.
Mr Lee had got the top job through an uncontested election - a sore point for many Hongkongers who say China has gone back on its promise to make the process fully democratic eventually.
Mr Lee's new 21-member cabinet was also sworn in. It is heavily staffed by pro-Beijing leaders, including three who have been sanctioned by the US for "undermining Hong Kong's autonomy and restricting the freedom of expression or assembly" of its people.
Various official events celebrating the handover will be held across the city on Friday, a public holiday. They typically culminate in a firework display over Victoria Harbour.
Mr Xi's visit this year - the first to Hong Kong since the 20th anniversary celebrations in 2017 - has led to the city deploying plainclothes officers and "special constables" drafted from prison guards and immigration forces, reports BBC Chinese's Martin Yip.
An Omicron outbreak earlier this year in Hong Kong fuelled doubts over whether Mr Xi, who has personally championed China's zero Covid policy, would cancel his visit.
But he arrived in Hong Kong on Thursday via a high-speed train and met outgoing chief executive Carrie Lam.