LABOUR delivered an emphatic victory over the SNP in the Glenrothes by-election early this morning, giving a massive fillip to Gordon Brown and his attempts to reassert his party's authority throughout the country.
Lindsay Roy, the Labour candidate, was declared the winner at 12:45am, beating Peter Grant, his SNP rival, by 6,737 votes – a far greater majority than even the Labour Party had expected.
Mr Roy's win gives the first serious indication of a recovery in Labour's political fortunes in Scotland since last year's Holyrood elections.
In his victory speech, Mr Roy credited his achievement to the Prime Minister. He said: "With Gordon Brown, Britain is strong. With Gordon Brown, Labour has won here in Glenrothes and Central Fife."
The result represents a major blow to the SNP. Labour was defending a 10,664 majority in Glenrothes but, because of the SNP's success in Glasgow East and Labour's deep unpopularity across the UK, the Nationalists had been expected to win this by-election.
But despite achieving a 5 per cent swing in the vote, the "political earthquake" to rival Glasgow East predicted by Alex Salmond, the SNP leader and First Minister – who wagered his own money on victory – never appeared. Instead, it is Mr Brown who is celebrating. The Prime Minister had gambled himself, by investing his own political credibility in a Labour victory.
A source close to Mr Brown told The Scotsman last night: "Given how confident the SNP have been, saying 'Yes we can win and yes we will win', it shows how out of touch they are with what's happening on the ground.
"We have been working very hard to do what we can to help people through these difficult economic times. It seems to have hit home."
Mr Brown is expected to make a statement on the win today.
David Cameron, the leader of the Conservative Party, who is in Glasgow, no doubt had hoped to underscore a Labour defeat; however he will now have to concede that the "Brown bounce" could still hamper his ascent to No10.
Mr Brown visited the constituency twice to campaign. In doing so, he not only broke the convention that prime ministers do not campaign in by- elections, but also tied his party's fortunes to his own.
Had Labour lost, his own authority would have been undermined as he had chosen to lead the Labour effort from the front. But this victory makes his political judgment look inspired and his interventions decisive.
In national terms, the win will secure Mr Brown's leadership for the foreseeable future, providing the sort of electoral turnaround that no-one expected just a few weeks ago, when he was fighting for his political career.
Labour managers celebrated in Glenrothes early this morning, convinced that the "Brown bounce", which began with his handling of the global economic crisis, had helped retain this seat and prevent it from falling into SNP hands. When the result was announced, to cheers and shouts of joy from Labour activists in the Fife Institute in Glenrothes, it was clear that, as expected, this by-election had come down to a straight contest between Labour and the SNP.
Labour's Mr Roy won 19,946 votes, 55.1 per cent of the total cast, with the SNP's Mr Grant getting 13,209 votes, 36.5 per cent of those cast.
Privately, SNP sources admit that they were very close to guessing their support, within just 140 or so votes. But they had underestimated how the votes would fall to the other parties, particularly Labour, which benefited from a bigger than expected turn out.
"Another lesson we have learned, unfortunately, is that negative campaigning works. Lindsay Roy has been going out there saying that we have cut school budgets, when we have actually poured 25 million in."
Peter Grant, the SNP candidate who had been expected to win until a few hours before the polls closed, praised his team as the "most positive and hard working" of any.
He said the SNP had still made significant progress in reducing Labour's majority.
The Tories were third, with 1,381 votes (3.8 per cent) with the Lib Dems fourth , with 947 votes (2.6 per cent). Both parties lost their deposits. Turnout was disappointing for a contest that had attracted such intense media attention; only 52.37 per cent of the local electorate voted in the grey and damp conditions yesterday.
Sir Menzies Campbell, the former Lib Dem leader whose seat neighbours Glenrothes, said: "Smart Alec has had his comeuppance. Once again, an extravagant prediction from Mr Salmond has proved worthless. This is a personal achievement for the Prime Minister."
Harry Wills, the Liberal Democrat candidate who was beaten into fourth place said: "The SNP juggernaut has been stopped in its tracks. Alex Salmond promised us an earthquake but by November the 5th and 6th, it has turned into a damp squib."
Maurice Golden, the Tory candidate, said: "It is clear that people are rejecting Alex Salmond. The bubble has well and truly burst." Despite losing his deposit, he added that he was "delighted" to have beaten the Lib Dems. "We fought a positive campaign and third is a fantastic result for us. Scottish politics is a three-horse race."
He also praised Mr Roy as a "genuine maverick" and added that his victory had been one for "unity and the United Kingdom" adding that pushing the Lib Dems into fourth place showed "Scottish politics is increasingly a three horse race."
John Park, a Labour MP and one of the party's campaign managers, said: "I think Gordon Brown's intervention in this campaign was vitally important: he cares about the community." The Prime Minister's own constituency, Kirkcaldy and Cowdenbeath, neighbours the Glenrothes seat.
The by-election was caused by the death of the Labour MP, John MacDougall, in the summer, after a long battle with cancer. He was a well-liked and respected MP and a good friend of the Prime Minister.
In normal circumstances, that background, plus his sizeable majority in a traditional Labour area, should have been enough for the party to be confident it could retain the seat.
However, following the SNP's "political earthquake" in winning Glasgow East in July, combined with Labour's deep unpopularity through the late summer and early autumn, the SNP went into the contest as clear favourites.
The odds on a Labour revival and victory shortened throughout the campaign as Mr Brown's work in securing global agreement for a worldwide bank rescue package began to shore up the party's vote.
By the time the Prime Minister visited the constituency for the second time, a week ago, Labour had closed the gap to such an extent that bookmakers refused to pick a favourite – tying the SNP and Labour on odds of 5/6 going into the final week.
But over the last weekend, when the SNP brought in an extraordinary 1,200 activists to the constituency, the Nationalists pulled ahead once more, allowing Mr Salmond to be so confident that he bet on Mr Grant's success.
A key plank of Labour's campaign was to rail against care charges imposed by the SNP Fife Council. The party claimed the ill and elderly were being penalised as home care costs in Fife had risen from 4 a week for pensioners and vulnerable people to 11 an hour under the SNP/Lib Dem council.
This issue was again raised by Mr Roy in his victory speech, aware of how important it had been for him on the doorsteps. He said: "The charges and cuts to elderly and disabled from the SNP council must stop now; so must the cuts in school budgets. This is the message we have heard from the people of Glenrothes."
Labour was widely credited for running a good campaign and winning the media "airwaves war", but the SNP's strength of support on the streets, combined with a solid campaigning machine, was believed by many to be enough to see the Nationalists to victory.
However, it will now be Mr Roy, not Mr Grant, who heads to Westminster as Scotland's newest MP in the coming days.
• Analysis: PM slams the brakes on Salmond's momentum
• In pictures: Scenes from the Fife Institute in Glenrothes
• Gerri Peev's by-election blog