Despite fears the vote could be disrupted or cancelled over the unrest, it went ahead peacefully.
The election was seen as a test of support for the government after months of unrest, protests and clashes.
The government and Beijing had been hoping the election would bring a show of support from the so-called “silent majority”, but that did not materialise. Instead some significant pro-Beijing candidates lost council seats.
One controversial pro-Beijing lawmaker, who lost his seat, Junius Ho, said “heaven and earth have been turned upside down”.
Why is this vote so important?
Hong Kong’s district councillors have little political power and mainly deal with local issues such as bus routes and rubbish collection, so the district elections don’t normally generate such interest.
But these polls were the first time people could express at the ballot box their opinion on embattled Chief Executive Carrie Lam’s handling of the crisis, which was sparked by a now withdrawn extradition law.
Also, 117 of the district councillors will also sit on the 1,200-member committee that votes for the chief executive, so a pro-democracy district win could translate eventually to a bigger share, and say, in who becomes the city’s next leader.
A record 4.1 million people had registered to vote – more than half the population – and more than 2.9m people cast votes.
That’s a turnout of more than 71%, against 47% in 2015.
The weekend was also the first in months without any clashes between protesters and police.
What does it mean for Hong Kong?
Over the past months, demonstrations and unrest had been gradually escalating.
Police have at times used live rounds, wounding several protesters. Activists in turn have attacked police or in one case set alight a government supporter.
It was unclear how much of the general population still supported the protesters, and authorities had been hoping the election would identify the protesters as a small group of fringe extremists.
But in many districts, young first-time candidates, many who had explicitly aligned themselves with the protesters, unseated established politicians backing the government.
The hope from activists is that the overwhelming victory of anti-establishment parties will force the government to take protesters’ demands more seriously.
‘A wipeout beyond imagination’
Stephen McDonell, BBC China correspondent, in Hong Kong
Outside the Yau Ma Tei North polling station, local residents lined up to gain entry so they could watch the vote count. The doors opened and they poured into the public viewing area.
Six months into an ongoing political crisis, people have lost faith in government institutions. They wanted to make sure that this process was fair and transparent.
As they waited for the total in their own district council to be tallied, they could see the numbers coming in from elsewhere on their mobile phones.
By their facial expressions it was clear they couldn’t believe what was unfolding, and people cheered in astonishment as one surprising result came in after another.
Nobody imagined such a comprehensive wipeout, and Carrie Lam’s administration will no doubt come under renewed pressure to listen to the demands of protestors following such an overwhelming defeat for her and her allies.
Big winners and losers
More than 1,000 candidates ran for 452 district council seats which, for the first time, were all contested. A further 27 district seats are allocated to representatives of rural districts.
Pro-Beijing parties held the majority of these seats ahead of the election.
In one of the biggest losses for the pro-Beijing camp, lawmaker Junius Ho – one of Hong Kong’s most controversial politicians – suffered a shock defeat.
He was stabbed earlier this month by a man pretending to be a supporter. The lawmaker has openly voiced his support for Hong Kong’s police force on multiple occasions. He was in July filmed shaking hands with a group of men – suspected of being triad gangsters – who later assaulted pro-democracy protesters.
Jimmy Sham, a political activist who has recently risen to prominence as the leader of the Civil Human Rights Front – a campaign group responsible for organising some of the mass protest marches – won a seat after running for the first time.
Mr Sham has also been attacked twice, once apparently with hammers. Photographs at the time showed him lying on the street covered in blood.
After the vote, Mr Sham said “we have to be leaders of the community that listens to people’s voices and opinions”.
Pro-democracy activist Joshua Wong was barred from running in the elections, a move he referred to as “political screening”, but the pro-democracy candidate who replaced him has won.
In a tweet, Mr Wong said the “historic” results showed that public opinion had not turned against the pro-democracy movement.
Reflecting on her reported defeat, pro-Beijing lawmaker Alice Mak suggested Ms Lam’s administration was partly to blame.
“In the election campaign, pro-government candidates have been unfairly treated. This is a very important reason,” she said.
Starry Lee Wai-king, chairwoman of the city’s largest pro-Beijing party, was among the few establishment candidates to secure her seat.
“I think [Lee] is the only one who can survive the de facto referendum,” said Leung Kwok-hung, her pro-democracy opponent in the poll.