The SNP’s former leader Alex Salmond has lost his Gordon seat to the Scottish Conservatives.
The Tories also defeated the SNP’s deputy leader Angus Robertson as they surged across Scotland.
The SNP are currently on 33 seats – a majority of the 59 Scottish constituencies but a big drop from the 56 they won in 2015.
The Conservatives have won 12 seats in Scotland so far, with Labour winning seven and the Liberal Democrats three.
The Tories have seen big increases in their vote across the country, with the SNP vote dropping sharply.
But the picture is less positive for the Conservatives across the UK, with the party expected to lose its majority at Westminster and the election predicted to result in a hung parliament.
Mr Salmond had won a majority of 8,687 at the last election in 2015 – but the Conservatives saw their share of the vote increase by 29% as Colin Clark defeated the former first minister by 2,607 votes.
Despite his defeat, Mr Salmond insisted that people have “not seen the last of my bonnets and me”.
He added: “The SNP have lost many fine parliamentarians this evening and that’s a grievous blow to the SNP.
“But overall the result in Scotland shows the SNP will have won a majority of the seats in this country and the majority of the vote, something which I suspect the prime minister would like to be able to claim in the early hours of this morning but is not able to do so.”
Earlier, Douglas Ross of the Tories overturned a majority of 9,065 to defeat Mr Robertson – who had been the SNP’s leader at Westminster – by 4,200 votes in Moray.
The SNP’s Tasmina Ahmed-Sheikh has also lost Ochil and South Perthshire to the Tories, who were a distant third in 2015.
John Nicolson of the SNP lost Dunbartonshire East to Jo Swinson of the Liberal Democrat, who have also won Edinburgh West and Caithness, Sutherland and Easter Ross.
The results mean that the SNP has lost its Westminster leader, chief whip, foreign affairs spokesman and international trade spokeswoman.
Speaking as she arrived at the Glasgow count, First Minister Nicola Sturgeon said that the SNP had won the election in Scotland, with the party achieving its second best performance ever in a Westminster election.
Asked about the impact of the lost SNP seats on her desire to hold a second independence referendum, Ms Sturgeon said: “Like most politicians I have not had any sleep and I am not going to take any rash decisions.
“Clearly I have to reflect on the result of the election and I will take time to do that. But it would be the wrong thing for me to do at this hour to take decisions before having had the opportunity to properly think about it.
“But properly think about it I will certainly do”.
Scottish Conservative leader Ruth Davidson hailed a “historic” night for her party, which she said was largely due to Ms Sturgeon’s attempts to “ram-raid through” a second independence referendum.
She said: “Indyref2 is dead. That’s what has happened tonight”.
And Labour’s Ian Murray, who increased his majority in Edinburgh to more than 15,000, said voters had “hammered the final nail into the independence coffin”.
There was better news for the SNP in Paisley and Renfrewshire South, where Mhairi Black kept her seat despite a big drop in her share of the vote.
Ms Black, the youngest MP at Westminster in the last parliament, had her majority over Labour cut from about 6,000 to about 2,500.
Elsewhere, Stewart Hosie held Dundee East – which had been the safest seat in Scotland – for the SNP, while Angus MacNeil held on in the Western Isles, despite his share of the vote falling by nearly 14%.
Pete Wishart also held on for the SNP in Perth and Perthshire North after finishing just 21 votes ahead of the Tory candidate, while Tommy Sheppard held Edinburgh East.
An exit poll had predicted that the SNP would lose 22 of the 56 seats it won in the last election in 2015.
The poll, which was taken at polling stations across the UK, also suggests the Conservatives will fall short of an overall majority at Westminster.
SNP politicians had cast doubt on the exit poll result when it was first published – with many insisting the party would not lose as many as 22 seats.
Sorry, your browser cannot display this content.
Find your constituency
Enter a postcode or seat name