HONG KONG — Election posters promoting the candidate for Mongkok North left no doubt about his affiliations: Wearing all-black clothing, a yellow hard hat, respirator and goggles, he was firmly aligned with protesters seeking full democracy.

“Five demands, not one less,” read the banner, the mantra of the grass-roots uprising countering China’s tightening grip on Hong Kong.

In defeating the incumbent establishment candidate, Lucifer Siu contributed to a landslide win for the democracy camp in Hong Kong’s district council elections. A similar story unfolded citywide: A 23-year-old graduate beat a three-time incumbent in an establishment stronghold; a 25-year-old who crowdfunded his campaign ousted the vice chairman of the main pro-Beijing party.

More than 2.9 million voters — a record turnout — delivered the pro-democracy camp 17 of 18 districts and more than 80 percent of contested seats, the biggest electoral victory for the movement since Hong Kong’s handover from British rule in 1997. But it was also a rare chance for people within China to send their leaders a clear electoral message — that they want democracy, not overbearing control by Beijing, and that they were prepared to look past protesters’ violence.

With this rebuke of its affiliates in the city, Beijing faces a tough choice: whether to open up politics as promised in Hong Kong’s mini-constitution, extend a crackdown on the pro-democracy protesters by the city’s police force and government, or try to navigate a delicate middle path.

Beijing can continue to dig in, but it would risk escalating and prolonging the conflict now that the electorate has spoken, said Ho-Fung Hung, an expert on the Chinese political economy and Hong Kong politics at Johns Hopkins University’s School of Advanced International Studies.

“A wiser path is to replace Carrie Lam and reset the conversation,” he added, referring to Hong Kong’s chief executive.

Reacting to the outcome on Monday, Chinese state media accused foreign forces, particularly the United States, of interfering. “China will respond tit-for-tat and resolutely counter any move by the U.S. that undermines China’s interests, and will never let them act willfully on Hong Kong affairs,” the official Xinhua News Agency said in an editorial.

In a commentary, the nationalist Global Times tabloid called for “rational analysis,” noting that Hong Kong’s recent unrest helped the democracy camp to mobilize support. “It is crucial to rationally interpret” the results, it said, “lest mobs should be emboldened by misreading them.”

The vote’s outcome surpassed even the most optimistic predictions among the pro-democracy camp, which had barely held 30 percent of district council seats previously.

Pro-democracy parties won 347 district council seats of the 452 up for grabs, with pro-Beijing candidates taking 60 and independents winning 45 seats, according to figures compiled by the South China Morning Post.

The district councils nominate 117 members to the 1,200-member election committee that chooses Hong Kong’s leader. That panel is typically dominated by pro-Beijing forces and sympathetic business interests, but pro-democracy forces will now have considerably more influence to add to their existing support.

“It gives them probably not a majority but a meaningful chunk, and puts them in a position to be kingmakers,” said Antony Dapiran, a lawyer and author of books on Hong Kong’s protest movement.

Lam, Hong Kong’s embattled leader, said in a statement Monday that her government respects the election results, and she acknowledged “various analyses and interpretations.”

“Quite a few are of the view that the results reflect people’s dissatisfaction with the current situation and the deep-seated problems in society,” Lam said. “The Hong Kong government will listen to the opinions of members of the public humbly, and seriously reflect.”

Susan Shirk, a China expert and former Clinton administration official who is now at the University of California at San Diego, said it was possible that Chinese leader Xi Jinping had not received accurate information from lower-level officials on the public dissatisfaction in Hong Kong, despite months of protests.

“No one has wanted to give him bad news,” she said. “The more than 70 percent of the Hong Kong public who voted in this election sent him a message he can’t ignore.”

Frank Pieke, director of the Mercator Institute for China Studies, a think tank in Berlin, said China’s leaders “must be scratching their heads and wondering, ‘What are we going to do now?’ ” He added, “What they will have to do in Beijing is finally think about some concessions they will have to make.”

Pieke said those concessions did not necessarily have to be large but could include, for example, an independent inquiry into allegations of brutality by Hong Kong police and protesters during the demonstrations.

There is no sign, however, that Beijing is prepared to grant Hong Kong the freedom to elect a government truly accountable to its own people, and one that could potentially represent the interests of the territory against those of the Communist Party, experts said.

Hong Kong’s pro-democracy bloc was quick to celebrate its new status as the largest party in the district council, ending the dominance of the pro-Beijing Democratic Alliance for the Betterment and Progress of Hong Kong, or DAB, which fielded 181 candidates but won just 21 seats.

“The district council election fully shows that Hong Kong people will not accept the authoritarianism of the central government,” said Wu Chi-wai, chairman of the Democratic Party. “The Hong Kong government must now seriously consider public opinion.”

Wu added that his party will push for Lam’s resignation and overhauls of Hong Kong’s government and political system, as well as more police accountability.

Late Monday, the newly elected democratic representatives pressed for a solution to the siege of a university campus where a handful of protesters remain holed up after more than a week. The campus of Hong Kong Polytechnic University was the scene of the biggest escalation of violence since the start of the protest movement.

DAB, meanwhile, acknowledged its poor showing. The party, which has the support of Beijing’s liaison office and maintains close links to the Communist Party, backed a now-scrapped bill — the spark for the protests — that would have allowed criminal suspects to be extradited to mainland China.

“We have faced many challenges,” said DAB leader Starry Lee, who narrowly won reelection. “We do not want to find any excuses for our loss.”

In downtown Hong Kong, office workers wearing masks emerged from skyscrapers to celebrate the result. A man had popped a bottle of champagne and was distributing it in plastic cups to the crowd.

The celebrations kicked off when results started trickling in early Monday, particularly in the constituency where Junius Ho, a stridently pro-Beijing politician, lost his seat.

In July, Ho was seen shaking hands with members of a mob on the night they attacked pro-democracy protesters in a subway station. He has threatened to kill advocates of Hong Kong independence and recently used vulgar language toward a pro-democracy lawmaker. He has denied culpability in the mob attacks and says his threats have been taken out of context. He was also attacked with a knife and lightly injured during campaigning.

Anna Kam in Hong Kong and Liu Yang in Beijing contributed to this report.