BEIJING — Nearly three years ago, when thousands of pro-democracy demonstrators seized major roads in central Hong Kong for more than two months, they mocked President Xi Jinping and demanded that he allow a free vote for the city’s leader.

Mr. Xi never set foot in Hong Kong or addressed the protesters, but the local government, widely understood to have his blessing, offered no compromise, deployed the riot police to clear the streets and arrested the leaders of the rallies.

On Thursday, when Mr. Xi arrives in the city for the first time as China’s leader, he is unlikely to mention the 2014 upheaval that challenged his young administration, but it will lie behind his message of Beijing’s firm control.

He will take “a kind of carrot and stick approach,” said Willy Lam, a political commentator who teaches at the Chinese University of Hong Kong. “But more emphasis will be put on the harder line. The change of attitudes is more than just the personal thing of Xi Jinping. This reflects the entire paradigm shift between Hong Kong and China.”