The Scottish National Party has clung onto the safe seat of Aberdeen Donside - and its Holyrood majority - despite a loss of more than 5,000 byelection votes.
Mark McDonald, the victorious SNP candidate, won with 9,418 votes - 2,025 more than Labour's Willie Young, on 7,789. But that margin compares unfavourably to the 7,175 that the party won by in May 2011.
That year's election was won by popular MSP Brian Adam, whose death from cancer aged 64 triggered the byelection.
There was only a small swing to Ukip, whose candidate Otto Inglis lost his deposit with just 4.8 per cent of the vote - a relatively impressive showing for a Ukip candidate in Scotland.
Ukip leader Nigel Farage had said he expected the anti-EU party to produce its best ever Scottish parliamentary performance by retaining its deposit and possibly stealing fourth place off the Tories or Liberal Democrats, as his party built up momentum in Scottish politics.
Defeat for the SNP would have left them level with all the other parties combined in Holyrood, and at the mercy of votes from the two Scottish Green MSPs or the three independent MSPs.
Alex Salmond, the SNP leader and first minister, said: "This is a fantastic SNP win, and Mark McDonald will be a first-class representative for the people of Donside."
"Midway into our second term of government, and we have comfortably retained a seat which Labour once held – their failure to make significant progress is a major setback, and a rejection of the cuts commission agenda of [Scottish Labour's leader] Johann Lamont."
"I am also delighted that Ukip failed to retain their deposit."
Young, a local councillor, said he was very pleased with Labour's performance: "It's an absolutely huge reduction in the majority. I'm absolutely delighted with that. I'm very, very happy."