He cautioned that “making everything political or deliberately creating differences” will “severely hinder Hong Kong’s economic and social development.”
Mr. Xi warned that “any attempt to endanger China’s sovereignty and security, challenge the power of the central government” or to “use Hong Kong to carry out infiltration and sabotage against the mainland is an act that crosses the red line and is absolutely impermissible.”
His comments on “infiltration and sabotage” in particular signal that the government will likely try to resurrect security legislation, known as Article 23, against sedition and subversion, said Willy Lam, a political analyst and adjunct professor at the Chinese University of Hong Kong.
“This is the first time Xi Jinping or anyone in the leadership has mentioned a ‘red line,’” he said. “It’s a warning to the pro-independence or other so-called anti-China elements to not challenge the authority of the central government.”
Mr. Xi’s visit to the military garrison here furthered that message, Mr. Lam said. “It’s an implicit threat, if the Hong Kong police are not able to do the job or there’s widespread disorder, the troops will be mobilized,” Mr. Lam added.
Many people in Hong Kong have grown frustrated with high housing costs, a lackluster education system and an influx of millions of visitors from mainland China.
Mr. Xi said the key to Hong Kong’s success was the “one country, two systems” formulation, under which Hong Kong maintains its own legal, economic and local political system. But many in the city worry that the system is eroding under growing pressure from mainland China.
The disappearance of local booksellers and a politically connected billionaire, who were apparently abducted by mainland security officials, was seen as an example of the deteriorating rule of law and increased meddling from Beijing.
“Hong Kong originally had freedom of speech, but in the future, under the influence of the Chinese government, it won’t be so easy to speak out,” said Shandi Leung, 25, as she stood alongside the slow line of protesters walking through the Wan Chai district of Hong Kong island.
Around her, people carried signs for a host of causes: workers’ rights, community agriculture, independent media and Falun Gong, the spiritual movement banned in mainland China. They marched in stultifying heat and intermittent downpours, united by calls for a more direct say in their government and concerns their civil liberties are under threat.
“The Chinese government, they don’t want to listen to anyone in Hong Kong or anywhere else,” said Lam Ping, a 53-year-old hospital technician who carried a sign calling for the release of Liu Xiaobo, the Chinese Nobel laureate who was recently moved from prison to a hospital for cancer treatment. “They care about the one country, not the two systems.”
On Friday, Lu Kang, a spokesman for China’s Ministry of Foreign Affairs, said Hong Kong’s affairs were a domestic matter and the Sino-British Joint Declaration, which outlined Hong Kong’s return to China and the protection of basic rights for its population, was “history and of no practical significance.”
He was addressing comments by Boris Johnson, the British foreign secretary, on the importance of civil liberties in Hong Kong, and remarks by a U.S. State Department spokeswoman who said Washington was concerned about intrusions on freedom of the press and other rights in the city.
A British Foreign Office spokeswoman responded that the “Sino-British Joint Declaration remains as valid today as it did when it was signed over 30 years ago,” Reuters reported.
On the streets of Hong Kong, concerns about attacks on fundamental rights were evident. A group of prominent pro-democracy activists including Joshua Wong and Leung Kwok-hung, a local lawmaker, say they were set upon by thugs when they tried to protest outside a flag-raising ceremony Saturday morning. The police took away some of the activists but later released them.
One protester, Avery Ng, said he and another activist, Figo Chan, were assaulted by the police while they were in custody. The police media office did not answer calls for comment Saturday afternoon.
July 1 is a public holiday in Hong Kong to mark the handover to Chinese sovereignty, but it also has become a big day for pro-democracy protests. In 2003, a half-million people took to the streets to protest the government’s handling of the deadly SARS outbreak and efforts to enact the Article 23 national security law. The size of subsequent protests has varied as discontent with the government has ebbed and flowed.
In the fall of 2014, thousands of demonstrators occupied key roadways for months to demand the chief executive, Leung Chun-ying, step down and that the public be given a bigger say in choosing his replacement.
But Mr. Leung remained, finishing a term that ended Saturday. And Beijing refused to make any substantive changes to its proposal for the chief executive election, which allowed a public vote but only for candidates vetted by a pro-Beijing nominating committee.
Pro-democracy representatives in Hong Kong’s local legislature rejected the proposal. So the chief executive was chosen by the 1,194-member election committee, a body packed with supporters of Beijing. Ms. Lam, who served as Mr. Leung’s chief deputy, was elected in March with 777 votes despite trailing a more popular candidate in public opinion polls.
She gave a much shorter speech than Mr. Xi on Saturday, saying she would cultivate a “new style of governance to rebuild a harmonious society and renew the people’s trust in the government.”
Mrs. Lam delivered her speech in Mandarin, the national language of China, but she spoke briefly in Cantonese, the mother tongue of most Hong Kong residents, to read the lyrics of a song about social cohesiveness.