CHINA'S president, Hu Jintao, is a rare visitor to Hong Kong, and for all the pomp and ceremony surrounding his latest trip there on July 1st, he is doubtless relieved that he is not expected to return before he leaves office in a few months' time. Tens, perhaps hundreds, of thousands of people took to the streets in Hong Kong's, and China's, biggest protest in years. They vented grievances not only against Hong Kong's new leadership, which Mr Hu had just sworn in, but also against Beijing's. Mr Hu's successors will find Hong Kong's disgruntled public an increasing challenge to the Communist Party's troubled politics.

Colonial-era social freedoms still apply in Hong Kong, and pro-democracy groups in the territory have staged protests on July 1st ever since the first anniversary of the reversion to Chinese sovereignty 15 years ago. This year's demonstration was not as large as the one in 2003 that shocked the authorities in Hong Kong and Beijing and led to the eventual resignation of the former colony's chief executive, Tung Chee-hwa. But it was bigger than any since Mr Tung stepped down in 2005, with estimates of the turnout ranging from the official 63,000 to the demonstrators' 400,000. It was particularly potent because it coincided with Mr Hu's visit and the swearing in on July 1st of Hong Kong's new chief executive, Leung Chun-ying. No leader has taken up his post in the territory amid such a display of discontent.

Hong Kong officials were at pains to prevent Mr Hu from encountering any disaffected citizens, whose complaints range from Hong Kong's growing wealth gap to the mistreatment of dissidents in mainland China to allegations about Mr Leung's integrity. Security officials briefly detained a reporter who tried to shout a question at Mr Hu about the crushing of the Tiananmen Square protests in 1989, and a heckler at the swearing-in ceremony who also raised Tiananmen. Mainland Chinese media imposed a virtual news blackout on the demonstration. Chinese officials may well have noted, however, that among the demonstrators' hotch-potch of grievances those relating to China's politics were unusually conspicuous .

China's vice-president, Xi Jinping, who is all but certain to take over from Mr Hu as China's party chief late this year, and as president early next, will probably find Hong Kong politics even more troublesome than Mr Hu has. Mr Leung, the new chief executive, has been making an unusual effort to show his concern for Hong Kong's poor, but if his unpopularity persists in spite of that, it could lead to the kind of crisis that toppled Mr Tung.

Chinese leaders will also worry that political reforms in Hong Kong that are expected to begin in 2017 with the election of a chief executive by “universal suffrage”, will spur demands for similar change on the mainland. The Beijing government will no doubt find ways to control Hong Kong's shortlist of candidates but, unlike the recent selection of Mr Leung, who was returned by an electoral college consisting mainly of party sympathisers, the public is supposed to have the final say.

This will be less of a worry in Beijing if it turns out Mr Xi is keener on political reform in China than Mr Hu has been. Optimists took heart from the downfall of Chongqing's party chief, Bo Xilai, in March. Mr Bo was widely seen as politically conservative and intolerant of dissent. There has been no clear sign since then of a warming to the notion of political liberalisation, but in a couple of high-profile cases in the past year, senior regional officials have, unusually, made concessions in the face of popular demonstrations.

On July 3rd officials in the city of Shifang in Sichuan province announced that a planned copper-alloy plant would no longer be built after local residents demonstrated on the streets against it. In a sign that the central government is all too aware of the dangers of reacting too harshly to protests, official Chinese media have run editorials saying local government officials should learn lessons from the situation in Shifang. Meanwhile, though, many mainland activists continue to be harassed or held under house arrest.

Mr Xi himself has been playing his cards close to his chest. Government efforts to block internet circulation of a story by Bloomberg, an American news agency, about the enormous wealth of some of Mr Xi's relatives suggests he has only limited appetite for the public scrutiny of China's leaders. The assets described in the article include at least seven properties in Hong Kong, worth about $55m.