Naheed Nenshi has been re-elected for a third term as Calgary's mayor and all of the incumbent councillors have secured their seats following an election day marred by long voter lineups, ballot shortages and slow results.

Nenshi's main rival, Bill Smith, conceded at midnight when Nenshi had 112,503 votes to Smith's 97,756.

"Today, we confidently said as a people, as a community, that we will be bold, we will move forward and we will do it together," said Nenshi to a cheering crowd at The National bar on 10th Avenue S.W. after Smith conceded.

By about 6 a.m., with all 234 of 234 of the ward voting stations reporting and 32 of 32 city-wide voting stations reporting, Nenshi had 199,122 votes, compared to 169,367 for Smith.

Voter turnout was higher than it's been in more than four decades, with 387,306 votes cast by 58.1 per cent of the electorate, according to Elections Calgary.

Naheed Nenshi acceptance speech 0:30

Nenshi said he was humbled by the support and also from looking back on some of his mistakes over the past seven years.

"I can't promise you I'll be a different person and I'm not sure you want that, but I can promise you I'll do my very best, put my pants on every day and go to work every single day for every one of you," Nenshi said.

"Being your mayor is the best job in the world. This city is the best city in the world. And our best days are still ahead."

Smith calls for Calgarians to 'get behind our mayor'

A much shorter speech was delivered at Smith's election night headquarters earlier, as he conceded the campaign.

"I talked to Mayor Nenshi just a few moments ago to congratulate him," said Smith.

Bill Smith concession speech 0:24

"We've had what some suggest was a divisive battle over the last few weeks … and I think we need to put that aside and get behind our mayor and press the issues important to Calgarians that have to do with taxes, spending and how we treat Calgarians."

At one point, the race seemed split between Nenshi, Smith and Andre Chabot. But the longtime city councillor seemed to get squeezed out as the campaign progressed and he had garnered only 11,945 votes by early Tuesday morning when all the ballots were counted.

The other seven mayoral candidates racked up 6,872 votes among them.

Nenshi's path to victory

The once unassailable Nenshi was put on his heels during the campaign when two polls revealed he was well behind Smith, something contradicted by polls released from other organizations.

Jack Lucas, assistant professor of political science at the University of Calgary, said part of the reason for Nenshi's victory could be his support among young voters, a cohort that's less likely to vote, but can be a force when it does.

"It can mean voters are motivated to get out and vote to preserve the status quo, to resist the change," he said. "It's a pattern of mobilization and counter-mobilization."

Jyoti Gondek, shown in 2016, was elected as the city councillor for Ward 3 in Calgary's 2017 municipal election. She's one of four new faces on council. (Kyle Bakx/CBC)

The mayor ran on his record and a vision that includes an entertainment and cultural district in Victoria Park on the eastern edge of Calgary's Beltline neighbourhood.

It was that proposal that started off the campaign on an ugly note, when the owners of the Calgary Flames responded to Nenshi's proposal by saying they had walked away from negotiations with the city on a new hockey arena.

Nenshi maintained a strong lead throughout Monday night as results trickled in after polls closed at 8 p.m. MT.

Some polling stations were forced to stay open late because of a deluge of voters and a shortage of ballots.

Not only were some voting stations bursting at the seams, but results from the City of Calgary's live results website were slow to load and crashed repeatedly Monday night.

The city said it was aware of the problem and was looking at alternate ways to get the results out.

"It's a disservice to the people who are involved in politics and the people who are covering it and the citizens of Calgary to not have a quick and accurate count," said pollster Bruce Cameron.

"There's a lot at stake in elections. We've got to get it right and people at the City of Calgary have got to be looking in the mirror and saying 'fix this,' because this is inexcusable."

Gian-Carlo Carra celebrates after being re-elected councillor in Ward 9, as one of the many incumbents who were re-elected. (Sarah Lawrynuik/CBC)

4 new faces elected to council

Beyond the mayor's race, only four new council members will be going to work at City Hall — all four of them representing wards with no incumbent.

Here are the winners in each ward:

Ward 1: Incumbent Ward Sutherland.

Ward 2: Incumbent Joe Magliocca.

Ward 3: Jyoti Gondek.

Ward 4: Incumbent Sean Chu.

Ward 5: George Chahal.

Ward 6: Jeff Davison.

Ward 7: Incumbent Druh Farrell.

Ward 8: Incumbent Evan Woolley.

Ward 9: Incumbent Gian-Carlo Carra.

Ward 10: Ray Jones, who was previously councillor of Ward 5.

Ward 11: Jeromy Farkas.

Ward 12: Incumbent Shane Keating.

Ward 13: Incumbent Diane Colley-Urquhart.

Ward 14: Incumbent Peter Demong.

School trustees race

In the school trustee races, two of three incumbents running for re-election to the public board kept their seats:

In Wards 1 and 2, Trina Hurdman beat her only challenger, Gord Cummings.

In Wards 11 and 13, Julie Hrdlicka beat Sadiq Valliani, who was running under the conservative Students Count slate.

In Wards 5 and 10, Pamela King lost her seat to Marilyn Dennis.

In Wards 8 and 9, Richard Hehr won, beating his closest competitor, Sabrina Bartlett, by 14,723 votes to her 13,071 votes.

Students Count, which fielded five candidates running on the same platform, captured three seats — Althea Adams in Wards 3 and 4, Lisa Davis in Wards 6 and 7 and Mike Bradshaw in Wards 12 and 14.

All of the incumbents running for the Catholic board retained their seats.