The "Brown Bounce" was in full effect tonight as Labour comfortably held Glenrothes in a crunch by-election.
In a result that seemed to take even party insiders by surprise, their candidate Lindsay Roy coasted to victory with a majority of 6,737.
Although the margin was down a third on that achieved at the 2005 general election, the win will be seen as a huge personal boost for Gordon Brown.
Just a few weeks ago Glenrothes looked set to be the third safe seat Labour had lost under his leadership, with the poor performance sparking open calls for him to quit.
However, since then Mr Brown has been boosted by his handling of the global financial crisis, slashing the Tories' poll lead and seemingly impressing voters in Glenrothes.
The seat borders the Prime Minster's Kirkcaldy & Cowdenbeath constituency, and Mr Brown staked political capital by visiting it twice during the campaign - breaking the precedent that premiers stay away from by-elections.
Mr Brown's wife Sarah was also deployed to help bring in support.
Up until the count began tonight the SNP were expressing confidence that they had achieved the 12.3% swing needed to overturn the 10,664 majority. However, the mood soon changed, with one Labour official admitting he was "bewildered" by the turnaround.
Lindsay Roy (Lab) 19,946 (55.11%, +3.20%)
Peter Grant (SNP) 13,209 (36.49%, +13.13%)
Maurice Golden (C) 1,381 (3.82%, -3.28%)
Harry Wills (LD) 947 (2.62%, -10.04%)
Jim Parker (SSCUP) 296 (0.82%)
Morag Balfour (SSP) 212 (0.59%, -1.30%)
Kris Seunarine (UKIP) 117 (0.32%, -0.85%)
Louise McLeary (Solidarity) 87 (0.24%)
Lab maj 6,737 (18.61%)
4.96% swing Lab to SNP
Electorate 69,155; Turnout 36,195 (52.34%, -3.80%)
2005: Lab maj 10,664 (28.54%) - Turnout 37,366 (56.14%)
MacDougall (Lab) 19,395 (51.91%); Beare (SNP) 8,731 (23.37%); Riches
(LD) 4,728 (12.65%); Don (C) 2,651 (7.09%); Rodger (PPS) 716 (1.92%);
Balfour (SSP) 705 (1.89%); Smith (UKIP) 440 (1.18%)