You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Under the Single Transferable Vote (STV) system, voters rank their preferred candidates in order, and then have their votes redistributed to second or subsequent picks if their first choice is eliminated.
In results released this afternoon, based on 95% of votes counted, Green Party candidate and incumbent councillor Aaron Hawkins (with 15,060 votes) beat Cr Vandervis (13,306 votes) to the mayoralty by just over 1700 votes.
However, the results after each iteration of the counting process - as candidates dropped out one by one and voters' preferences were recalculated - showed Cr Vandervis led for much of the race.
It was only when Cr Christine Garey (with 6905 votes) was eliminated in the 12th iteration, and votes for her were redistributed to subsequent preferences, that Mr Hawkins went ahead.
That was perhaps not surprising, given both Cr Garey and Mr Hawkins had been endorsed as progressive potential leaders for the city by outgoing mayor Dave Cull.
A bigger surprise came in the 13th iteration, when Cr Andrew Whiley (who secured 9,409 votes) dropped out.
The redistribution of Cr Whiley's votes which followed might have been expected to favour Cr Vandervis, but instead went Mr Hawkins' way, helping him secure the mayoralty.
Earlier, Malcolm Moncrief-Spittle had become the first candidate eliminated from the mayoral contest, in the first iteration of the count, having secured just 229 votes.
The results were deemed progress results but updated figures were expected to be released on Sunday morning.
And, despite disappointment in the mayoral race for Cr Vandervis, he still managed to dominate the contest for council seats.
Cr Vandervis secured 6968 votes to secure a council seat, making him easily the highest polling councillor, followed by Cr Garey with just over half the support (3565 votes).
Cr Andrew Whiley was in third spot (2999) votes, followed by Cr Jim O'Malley just five votes behind, at 2904 votes.
At the other end of the spectrum, Dunedin businessman Russell Lund will be sweating on a last-minute change of fortune as final votes are counted.
Mr Lund missed out on securing the final seat at the table by just 67 votes to incumbent councillor Mike Lord.