Labour and the SNP are almost neck-and-neck in the race to win the 2007 Scottish Parliament election.
The Nationalists made significant gains, including Alex Salmond winning in Gordon and his deputy Nicola Sturgeon taking Glasgow Govan.
Labour has a total of 42 seats, The SNP has 42, The Liberal Democrats 16, the Conservatives 14 and the Greens one.
A number of results were delayed after technical problems caused several counts to be suspended.
In a night of high drama, Mr Salmond took the Gordon seat from the Liberal Democrats, while Ms Sturgeon won Glasgow Govan from Labour.
The SNP also took Dundee West, Central Fife, Stirling, Kilmarnock and Loudoun and Livingston from Labour.
Labour's Allan Wilson became the first minister to lose his seat when the Nationalists also claimed the Cunninghame North constituency.
Tommy Sheridan, of the left-wing Solidarity Party, also failed to get re-elected, as did Scottish Senior Citizens' Unity Party candidate John Swinburne and Scottish Socialist Carolyn Leckie.
Independent health campaigner Jean Turner was also ousted, after Labour took the crucial Strathkelvin and Bearsden seat.
David Whitton, who formerly worked as a spokesman for the late Donald Dewar, won with a 3,388 majority.
The changes in seats was not the only story of the election. There has been great controversy because of the new counting system employed for the first time.
The Holyrood poll will see 129 MSPs elected
The Electoral Commission is undertaking an inquiry into why up to 100,000 ballot papers were rejected by the high-tech counting machines.
Mr Salmond said on Friday afternoon that he would order a judicial inquiry if he wins power and becomes first minister.
At 1600 BST the majority of seats had come in and at that point Scotland's political editor Brian Taylor said outcomes could now be suggested.
In his blog, he speculated: "More gossip. How about 46 Labour (if they make that) plus 16 LibDems (if they make that) plus three Green (if they make that.) That adds up to 65.
"That adds up, just, to a coalition majority. Possible? Right now, almost anything's possible."
Mr Salmond said: "Scotland has changed for good and forever.
"There may be Labour governments and Labour first ministers in the decades to come, but never again will we say that the Labour Party assume that it has a divine right to rule Scotland.
"The Labour Party has no moral authority left to govern Scotland. Last night was a reminder that politicians exist to serve, not just to survive."
Former Scottish Tory leader David McLetchie retained Edinburgh Pentlands with an increased majority, adding: "It's been a terrific victory for us in this constituency and I couldn't be happier."
Jack McConnell won Motherwell and Wishaw
But he expressed disappointment at indications that he would not be joined at Holyrood by a Lothians list MSP and said he was "angry and frustrated" with the counting problems that delayed his result until 0600 BST.
The Tories snatched Roxburgh and Berwickshire from the Liberal Democrats, while also holding Galloway and Upper Nithsdale.
Scottish Labour leader Jack McConnell said it had been the toughest election in recent Scottish history.
He said: "We have won the debate. It remains to be seen tonight whether we have won the votes in individual constituencies.
"But whatever the result, I am sure the people of Scotland will be relieved that it is over, one way or the other."
Scottish Lib Dem leader Nicol Stephen said his party had positively campaigned in Scotland.
"The Liberal Democrats, in this new Scottish Parliament, are determined to deliver on our key policies," he said.
"My commitment is to these policies and to a bright future for Scotland."