The SNP still won a majority of Scotland’s seats at Westminster but, from a single seat before the election, the Scottish Conservatives took 13 from the SNP, sealing the party’s revival in Scotland and handing an electoral lifeline to Theresa May, UK Tory leader and prime minister.

Ruth Davidson, leader of the Scottish Conservatives, said the result showed Ms Sturgeon had been wrong to push for a second referendum to be held around the time the UK leaves the EU.

Mrs May had already rejected a second referendum and SNP leaders had been hoping public pressure would force her to rethink.

“We led the opposition to that referendum,” Ms Davidson said. “SNP MPs who last night lost their seats have paid the price for what was a massive political miscalculation on Nicola Sturgeon’s part.”

Ms Sturgeon insisted that the SNP’s haul of 35 of Scotland’s 59 seats was still a clear win, but acknowledged that the referendum push had been a factor in a victory far less emphatic than the 56 seats the SNP took just two year ago.

Asked if she would continue to push for a second independence referendum, Ms Sturgeon said she would reflect and “come to a considered judgment”.

However, there appears to be common ground between the SNP and Scottish Tories on Brexit.

Ms Sturgeon, who has complained bitterly about Mrs May’s pursuit of a “hard Brexit”, called for cross-party co-operation to protect jobs, preserve ties with Europe and bring order to negotiations.

“I’m appealing to MPs of all parties to join together to keep the UK and Scotland in the European single market,” the first minister said.

Ms Davidson, who has previously backed post-Brexit membership of the single market, stopped short of returning to that position but left no doubt she wanted Mrs May to soften her approach.

“The prime minister has made it clear it is her duty to get on with the job in hand and I support all efforts to do so,” Ms Davidson said. “[But] it is incumbent on us to listen to other parties in parliament, and people outside it, about the best way forward.”

While the Tories made the most progress in Scotland, the election also brought gains for Scottish Labour, who won seven seats, and the Liberal Democrats, who won four.

Ian Murray, who was the only Labour MP in Scotland to survive the electoral rout in 2015, retained his seat in Edinburgh South with a hugely increased majority. “Tonight the Scottish Labour party is back,” he told cheering supporters at the counting centre.

Scotland offered a valuable boost to morale for the battered Lib Dems, with Jo Swinson, one of the party’s young stars, winning by a landslide in East Dunbartonshire with the help of anti-SNP tactical voting by Labour and Tory supporters.

“Nicola Sturgeon, I hope you are listening,” said Ms Swinson, offering special thanks to voters who put aside their “usual party allegiance” to help her regain the seat she lost in 2015.

The election seemed likely to end the political career of former SNP leader and first minister Mr Salmond, a major figure in Scottish politics since the 1980s and the architect of the 2014 independence referendum.

Mr Salmond took comfort in the potential for even a much-reduced cohort of SNP MPs to have “very substantial influence indeed” in a hung UK parliament. And he hinted at a possible return to politics, referencing the end of a ballad about a 17th century Jacobite rebel. “You’ve not seen the last of my bonnets and me,” Mr Salmond said.

The loss of Mr Robertson — one of a number of SNP defeats in its previous stronghold of north-east Scotland — was another blow. The deputy party leader had been highly rated for his weekly exchanges with Mrs May as leader of the UK’s third-largest parliamentary party.