For the first time in over 30 years, Vancouver voters have elected an independent to the mayor's chair.

Kennedy Stewart, who was famously arrested protesting the Trans Mountain pipeline back in March, managed to narrowly beat out main rival Ken Sim of the Non-Partisan Association in a nail-biting finish.

Recent polls gave Stewart a comfortable double-digit lead over Sim, but the final results put him ahead by fewer than 1,000 votes: 49,812 to Sim's 48,828. 

The NPA candidate refused to concede early Sunday morning. 

Stewart will be the city's first independent mayor since Mike Harcourt left office in 1986, and will lead a divided council made up of Green, NPA, COPE and OneCity councillors. Not a single Vision Vancouver candidate won a seat apart from school trustee Allan Wong.

“It’s a diverse group of people but there is one thing that unites us. And that is that we love this city and we’re committed to making it better,” Stewart told his supporters during his victory speech. “I will work with every single person, no matter their political background, no matter their political party, to help make sure this city works for everyone.”

The results represent a major shake-up for City Hall, which has been Vision-dominated for 10 years. The only incumbents returning to council will be the Green Party's Adrian Carr and the NPA's Melissa De Genova.

Former NPA councillor George Affleck said outgoing mayor Gregor Robertson's decision not to seek re-election, and Vision's decision not to front any mayoral candidate, likely sealed the party's fate.

"Gregor was a very appealing leader and now they don't have a leader – very difficult to win an election if you don't have a leader," Affleck told CTV News.

Given the housing crisis plaguing Vancouver, many felt the writing was on the wall for both Robertson and Vision. Poll after poll leading up to the election identified housing as the number one issue among voters.

Every major candidate focused their campaign on affordability, and Stewart was no exception.

“When you talk to people on the ground, they are hurting. Their rents are going up, their moving out of the city and small business is feeling it. So, that’s got to be the number one priority for most councils across the Lower Mainland and I look forward to working regionally too,” Stewart said.

His platform included a promise to build 25,000 non-profit affordable rental homes over the next decade, which would be available to residents with a household income of up to $80,000.

He also pledged to build 35,000 condo units, coach houses and townhomes to help first-time buyers get into the market, and to renew leases to preserve Vancouver's 6,000 co-operative housing units.

The Greens elected three: Carr, entrepreneur Pete Fry and former park board commissioner Michael Wiebe. As an incumbent council candidate, Carr was the most popular candidate in the race, earning about 10,000 more votes than Stewart.

The fractured council will be rounded out by COPE's Jean Swanson and Christine Boyle of the new OneCity party. Boyle told CTV News she's hopeful they will be able to work together to address the many issues facing the city.

"One of the things I think we heard in this election was that people were tired of the old style of politics and they're ready for co-operation and they're ready for people to roll up their sleeves and get it done," she said.

"That's certainly my style and so I look forward to all of the elected councillors taking that attitude to the table."

It's unclear whether any of those issues actually motivated voters to turn up at the polls, but advanced polling numbers painted a promising picture.

According to the City of Vancouver, more than 48,000 people cast an advanced ballot this month, which is 27 per cent more than the 38,400 who voted early in 2014.

That election saw just 43 per cent of eligible voters turn up, and even that was an improvement over the dismal 35 per cent participation recorded in 2011.

Voters who did turn up were faced with a daunting list of 158 candidates for mayor, council, park board and school board. The ballot was 55 centimetres long, nearly 13 centimetres longer than usual, according to a tweet from the City of Vancouver.

And for the first time since the early 1990s, the candidates' names were listed randomly, rather than alphabetically – a move designed to remove an apparent advantage for candidates whose surnames start with the letters A, B, C or D.