HONG KONG — Partial returns early Monday from Hong Kong’s local elections showed that pro-democracy candidates won more than a third of the seats in balloting that was seen as a test of support for the anti-government protests that rocked the Chinese territory for more than five months.

Among the winners in Sunday’s vote that drew a massive turnout were former student leaders and a candidate who replaced prominent activist Joshua Wong, the only person barred from running in the election. Rally organizer Jimmy Sham, who was beaten by hammer-wielding assailants last month, also triumphed, as did a pro-democracy lawmaker who had part of his ear bitten off by an assailant.

So far, pro-democracy candidates have won 159 out of 452 seats in 18 district council races.

Hong Kong’s largest pro-Beijing political party suffered the biggest setback, with more than 100 of its 182 candidates defeated. Among the losing incumbents was controversial lawmaker Junius Ho, who was stabbed with a knife while campaigning this month.

The Electoral Affairs Commission said 71% of the city’s 4.1 million registered voters had cast ballots, well exceeding the 47% turnout in the same election four years ago.

The normally low-key race for the district councils, which are controlled by pro-establishment parties, took on new importance amid the protests. A strong showing by the opposition would signal that the public still supports the protesters, even as they resort to increasing violence.

“Symbolically, the message is clear. If the pan-democrats win, then it will be tantamount to a rejection of the hard-line policy of Beijing and the Hong Kong government,” said Dixon Sing, a political science lecturer with the Hong Kong University of Science and Technology.

The record turnout showed “a great groundswell in Hong Kong who believes in democracy,” said David Alton, a member of the British House of Lords who is among the international election observers invited by Hong Kong’s civil society groups.

During the months of demonstrations, protesters have smashed storefronts of businesses seen as sympathetic to China, torched toll booths, shut down a major tunnel and engaged in pitched battles with police, countering tear gas volleys and water cannons with torrents of gasoline bombs. More than 5,000 people have been arrested.

One voter, Christina Li, said it was important for older people like herself to support the youth who are at the forefront of the protests.

“Younger generations might not be able to enjoy the rights that we are enjoying now,” she said as she waited in line outside a polling station. “We cannot take it for granted.”

Many people in Hong Kong share the concern of protesters about growing Chinese influence over the former British colony, which was returned to China in 1997.

The protests started in June over a now-abandoned extradition bill that would send criminal suspects for trials in mainland China. But the movement has expanded to include demands for democratic elections for the city’s leader and legislature, and an independent probe into alleged police brutality in suppressing the protests.

Voting was peaceful amid tight security, with hardly anyone seen wearing protesters’ trademark black clothing or face masks. Many voters turned up early to cast their ballots, leading to long lines that extended for blocks.

The vote is the only fully democratic one in Hong Kong. Members of the legislature are chosen partly by popular vote and partly by interest groups representing different sectors of society, and the city’s leader is picked by a 1,200-member body that is dominated by supporters of the central government in Beijing.

Both the ruling camp in Hong Kong and the Chinese central government were hoping that the unrest, which has disrupted daily life and contributed to the city’s first recession in a decade, would turn voters against the protesters.

Political analyst Sing said public opinion polls showed that many citizens blamed the violence on the government and police handling of the conflict.

A win would bolster the democrats’ influence and give them 117 seats in the panel that elects the city’s leader, but Beijing isn’t likely to soften its stance or make any concessions to the protesters, he said.

There has been a rare break in the violence in recent days as protesters, eager to validate their cause at the ballot box, hit the pause button to ensure the polls wouldn’t be postponed.

Hong Kong leader Carrie Lam, who is reviled by the protesters, said after voting Sunday morning that she hoped the calm will last.

“I hope that … the election will show that everyone doesn’t want Hong Kong to return to chaos again, that we want a way out of this crisis so that we can have a fresh start,” Lam said.

Associated Press videojournalists Dake Kang and Katie Tam contributed to this report.