The SNP has secured an unprecedented victory by taking a majority of seats in the Scottish Parliament election.
Alex Salmond's party passed the half-way point by taking its 65th seat in a historic win at Kirkcaldy, the first time gains on this scale have been achieved since the Parliament was established in 1999.
The decisive victory comes at the heavy expense of Labour in what were considered heartland territories, and with a collapse in the Liberal Democrat vote.
Labour's defeat led the party's leader Iain Gray to announce that he will stand down in the autumn.
Mr Gray only held on to his East Lothian constituency by 151 votes over SNP candidate David Berry, prompting calls for a recount.
With three regional lists to be declared, the SNP had 65 seats, with Labour trailing on 29 MSPs. The Conservatives had nine, the Lib Dems four and the Scottish Greens one.
The win is further symbolic because Kirkcaldy was considered a solid Labour area, with the overlapping Westminster constituency held by former Labour prime minister Gordon Brown.
It also means a referendum on Scottish independence can now be pushed through the Holyrood chamber - a proposal which failed to gain majority support in the last parliament.
First Minister Mr Salmond is expected to land by helicopter in Edinburgh later, where he will deliver a victory speech after a night of surprises across Scotland.
Mr Gray said: "It is now clear that the SNP has won the election, so early this morning I spoke with Alex Salmond to congratulate him on his victory.
"Labour has lost many talented representatives and it seems very likely that Labour's new and returning MSPs will play their part in the democratic process in the Scottish Parliament from opposition, but will do so with gusto.
"Labour's MSPs will work constructively with the new Scottish Government to create jobs and tackle unemployment wherever we can."
Shocks came quickly after polling stations closed last night, with major Labour politicians finding themselves out of a job.
Seat after seat in Glasgow, Lanarkshire and Edinburgh fell to the SNP, which also enjoyed a clean sweep of the entire north-east region.
The electoral map of Scotland appeared drastically different, with swathes of SNP yellow stretching unbroken from the Borders in the south to Thurso on the north coast.
Candidates once thought of as potential Labour frontbenchers lost out, including former ministers Andy Kerr, Tom McCabe and Frank McAveety.
Former Scottish Conservative leader David McLetchie was unseated in Edinburgh Pentlands.
But the Lib Dems appeared the biggest losers, with heavy falls in the share of votes and a high number of lost deposits.
Leader Tavish Scott held on to Shetland with a reduced share but his party was beaten in areas where it had previously enjoyed a comfortable majority.
The party's finance spokesman, Jeremy Purvis, was ousted by the SNP's Christine Grahame, who took Midlothian South, Tweeddale and Lauderdale with 43.51% of the vote.
SNP leader Mr Salmond, who won Aberdeenshire East with about 64% of the vote, hailed the "spectacular" successes.
He said wins across the country meant the SNP can now properly be described as the "national party", represented in all parts of Scotland.
In 2007, the SNP beat Labour nationally by just one seat to become the largest party at Holyrood, forming a minority administration led by Mr Salmond.
A second Green candidate was elected to parliament through the Lothian list, taking the party's tally back to the level of the last parliament.
But co-leader Patrick Harvie said he was "disappointed" not to have made the much-touted breakthrough in regional ballots across the country.
"I'd be lying if I tried to hide my disappointment," he told the BBC.
"I did hope for a bigger group in the Scottish Parliament in the new session. If we're at a standstill of two, or if we're at a slight increase, I'll have to admit I'll be disappointed."
Veteran politician Margo MacDonald was also re-elected on the list. In the last parliament, the former SNP MP failed to make Scotland the first part of the UK to legalise assisted suicide and pledged to try again this time around.
Labour leader Ed Miliband said: "I respect the decision Iain Gray has made today and I want to thank him for everything he has done for the Scottish Labour Party.
"While we have seen good results today, gaining councils and councillors across England and winning in Wales, this is clearly a very disappointing election result in Scotland.
"We need to learn the lessons of that result, both political and organisational. That is why I, with Iain, am today putting in place a root-and-branch review of the Labour Party in Scotland. This will bring together all elements of the Scottish Party to renew it for the future."
Mr Gray said election night was "dreadful" for Labour and promised to take time to assess what happened before standing down.
"It was a dreadful night and I acknowledge that, the Labour Party has to accept that," he told BBC Scotland.
"There are some very hard and fundamental lessons for the Scottish Labour Party, not least about my own responsibility in the role as leader of Labour in the Scottish Parliament.
"I want to start that process off but in the autumn I will stand down and it will be for the Labour Party to decide how we go forward from there."
Mr Gray also said he would like to offer SNP leader Alex Salmond his "unstinting congratulations" for an "absolutely remarkable achievement".
The final results for the Scottish Parliament election put the SNP on 69 seats, Labour on 37, Conservatives on 15, Liberal Democrats on five and Greens on two. Independent MSP Margo MacDonald was also returned to parliament.