The SNP held the Aberdeen Donside Holyrood seat early today but with a sharply reduced majority in the by-election.

Candidate Mark McDonald entered the Beacon Centre in Bucksburn and gave a victory salute to supporters before the formal declaration just before 2am.

However, his margin over Labour's Willie Young was only just over 2000, and there was a 9% swing to Labour from the SNP.

The SNP vote share fall in Aberdeen Donside was echoed today in the Glenrothes North, Leslie and Markinch poll at Fife Council, where Labour's John Wincott won with a 5.5% swing from the SNP.

And Laboour were celebrating after taking a marginal council seat in Edinburgh from the SNP. Keith Robson triumphed in Liberton/Gilmerton.

Since the independence referendum agreement announcement last October, the SNP vote share has now fallen in seven out of nine council by-elections as well as at Donside.

In Aberdeen, the LibDems'  Christine Jardine came third, edging the Tories' Ross Thomson into fourth and increasing her party's share of the vote by 2%.

UKIP were fifth, but failed to save their deposit.

Turn-out was 39%, regarded as respectable given the 47% who went to the polls at the last Scottish election in 2011.

Candidates spent a final day urging voters to turn out and support them as the replacement for veteran SNP MSP Brian Adam, who died earlier this year.

The SNP was defending Mr Adam's majority of 7175 from the last election in 2011. Mark McDonald gave up a regional Holyrood seat to stand in Donside.

ABERDEEN DONSIDE RESULT: Mark McDonald (SNP) 9,814 (41.98%, -13.29%), Willie Young (Lab) 7,789 (33.32%, +4.86%), Christine Jardine (LD) 1,940 (8.30%, +2.30%), Ross Thomson (C) 1,791 (7.66%, -0.43%), Otto Inglis (UKIP) 1,128 (4.83%), Rhonda Reekie (Green) 410 (1.75%), Dave MacDonald (Nat Front) 249 (1.07%, +0.27%), Tom Morrow (SCP) 222 (0.95%), James Trolland (SDA) 35 (0.15%).

SNP maj 2,025 (8.66%); 9.07% swing SNP to Lab; Electorate 60,242; Turnout 23,378 (38.81%, -8.86%).

2011: SNP maj 7,175 (26.81%) - Turnout 26,761 (47.66%).  Adam (SNP) 14,790 (55.27%); Crockett (Lab) 7,615 (28.46%); Thomson (C) 2,166 (8.09%); McLeod (LD) 1,606 (6.00%); Henderson (Ind) 371 (1.39%); Willett (Nat Front) 213 (0.80%)

FIFE COUNCIL RESULT

Glenrothes North, Leslie and Markinch: First count Lab 1896, SNP 1711, C 272, Ukip 176, Lib Dem 83. (May 2012 - Four seats Lab 1253, SNP 1193, 946, Lab 930, SNP 397, C 310, All Scotland Pensioners Party 226, Lib Dem 82. Elected: Lab 2, SNP 2). Lab hold. Swing 5.5% SNP to Lab.

EDINBURGH COUNCIL RESULT

Liberton and Gilmerton: First count Lab 2892, SNP 2249, C 823, Lib Dem 605, Green 412, Ukip 235, Ind 64, Pirate Party 47. (May 2012 - Four seats Lab 1941, SNP 1780, Lab 1768, C 1111, SNP 1084, Lib Dem 687, Green 469, Scottish Socialist Party 228. Elected: Lab 2, SNP 1, C 1). Lab gain from SNP.  (As no candidate polled more than 50% in the first count, votes are still being transferred from lower scoring candidates based on their supporters' alternative choices.)

The SNP hailed the Aberdeen Donside result. Deputy First Minister Nicola Sturgeon said winning in the city reflected well on the party approaching half way through its second term of government at Holyrood.

Ms Sturgeon said: "For a government that is mid-term into our second term of government, this was an exceptional result and a fantastic victory.

"People responded positively to the SNP's record in government, our billion pounds of investment in Aberdeen's infrastructure, and of course Brian Adam's legacy."

She dismissed Labour's challenge as a "powderpuff performance" and said: "The swing to Labour was just 9% - a very poor result after six years in opposition."

First Minister Alex Salmond, the SNP leader, congratulated his candidate shortly after the victory was declared in the early hours.

"This is a very bad result for Labour," he said.

"After six years of opposition, they show no sign of being anything more than an opposition party.

"I am also delighted that Ukip failed to retain their deposit. They have never saved a single deposit in Scotland, which once again demonstrates a clear divergence between Scottish and Westminster politics."

Despite defeat in Aberdeen,  Anas Sarwar, deputy leader of Scottish Labour, said: "All over Scotland, the momentum is with Scottish Labour and in Edinburgh, Fife and Aberdeen we have been gaining support from the SNP.

"Alex Salmond's obsession with the referendum is costing him votes.

"This week was an important staging post on our road back and while we know we still have some way to go, we are delighted with the progress we are making.

"It is important that Scottish Labour has the confidence to take our message to every part of the country and ask for support. That is what we have been doing over the last few weeks and that is what we will continue to do."

Scottish Lib Dem leader Willie Rennie said his party enjoyed a "triple boost".

He said: "Our share of the vote was up by a third, our number of votes was up and we were up to third place. As one of only two parties who saw an increase in votes in the Donside by-election, this is a solid result for the Scottish Liberal Democrats."

Tory candidate Ross Thomson suggested some of his vote went to Labour in an attempt to keep the SNP from winning.

"Because our voters are such committed Unionists, that had an appeal for some of them," he said.

The Scottish Green party contested the constituency for the first time, picking up 410 votes.

Party co-convener Patrick Harvie MSP said: "We worked hard to take our message on green jobs and public infrastructure to the community. We look forward to growing our campaigning in the north-east in the months and years ahead."