NICOLA Sturgeon is on course to suffer the worst electoral reverse for an SNP leader in almost 40 years, according to the national exit poll for the general election.

The BBC/Sky/ITV survey predicted the SNP would lose 22 of the 56 seats it won in 2015, taking 34 of the 59 constituencies in Scotland.

Former First Minister Alex Salmond in Gordon and SNP deputy leader Angus Robertson in Moray were both reckoned to be “under threat”, according to the poll.

Peter Wishart, the longest serving Scottish MP, would also lose in Perth & North Perthshire.

However the BBC warned the projections, based on just 10 polling stations in Scotland, should be treated with caution, as many of the seats involved were very finely balanced.

The result, if accurate, would mean Ms Sturgeon's party had still won the majority of seats in Scotland - the benchmark for success she set at the start of the campaign - but would undermine her claim to have a mandate for a second independence referendum.

However it could give the SNP group greater influence in a hung parliament at Westminster.

The projected 39 per cent loss of seats would be the worst for an SNP leader since 1979, when the party lost nine of the 11 MPs it won in the second general election of 1974.

Despite the same poll suggesting disaster for Theresa May across the rest of the UK, and the potentially fatal loss of her majority, it pointed to a raft of gains for the Scottish Tories.

Scottish Tory leader Ruth Davidson based her campaign on aggressively opposing Ms Sturgeon’s plan for a second referendum, and targeted a series of seats in the Borders, where Scottish Secretary David Mundell is defending his seat, but also pushed hard into traditional SNP heartlands in Perthshire and the north east.

The poll also suggested four gains for the LibDems in Scotland - East Dunbartonshire; Edinburgh West; Caithness, Sutherland & Easter Ross; Ross, Skye & Lochaber.

Scottish Labour was confident of holding Edinburgh South, with a 13 per cent swing away from the SNP on the basis of early postal vote sampling.

It was also close to taking its prime target seat of East Lothian.

Reacting to the poll, SNP social security minister Jeanne Freeman said it would still count as a good result if the SNP won more than 30 of the 59 Scottish constituencies.

Appearing on the BBC Scotland election programme, she said: “If we have a majority of seats in Scotland that will be a good result for the SNP.”

She said the SNP tsunami of 2015 was a “once in a century result”, adding: “Thirty-four, we would hope for better. But it is not a disaster for the SNP. It is a disaster for the Tories.”

Her fellow SNP minister Aileen Campbell called the result “disappointing”, but pointed out the SNP would remain the dominant party north of the border.

Former SNP deputy leader Stewart Hosie said the national result would be an extraordinary defeat for Mrs May, and the SNP would not want a Conservative government to be formed in its wake.

Former Labour minister Tom Harris said Mrs May's position would be "utterly untenable" if the poll results were borne out.

Liberal Democrat peer and former deputy First Minister Lord Nicol Stephen said: “Overall, I think the message here is for parties in government, this looks like a bad result for Theresa May in the United Kingdom going down, and for Nicola Sturgeon and the SNP in Scotland, going down to be honest far more than I ever expected - if this is true."

Former Labour MP Douglas Alexander said Mrs May had had “a disastrous campaign”.

He said: “I can genuinely say I can't remember a party leader having as bad a campaign as Theresa May. I'd suggest that Nicola Sturgeon couldn't find her footing in this campaign either."

Patrick Harvie, co-convener of the Scottish Greens, tweeted: “That’s something of a WOW exit poll. Fewer Tory seats would be great news for everyone who needs change so urgently.”

A Scottish Labour spokesman said: "Voters are increasingly fed up with Nicola Sturgeon and her abysmal record in government running our hospitals and schools.

“A majority of voters in Scotland also want Nicola Sturgeon to drop her plans for a divisive second independence referendum.

“Nicola Sturgeon and Theresa May have both fought terrible campaigns. The shine has come off Theresa May who hasn’t been able to defend her record or her policies.”

At the last general election, the SNP had 50 per cent of the vote. Scottish Labour won 24.3 per cent of the vote and one seat. The Tories won one seat with a 14.9 per vote share, and the LibDems one with 7.5 per cent.