Plans for a second vote on independence were a "significant motivator" in the General Election, Scotland's Deputy First Minister has said, after the SNP lost 21 seats in Westminster, including the shock defeat of former first minister Alex Salmond.

John Swinney said the SNP would "have to be attentive to that" - suggesting perhaps the party could draw back from its proposals.

Mr Swinney spoke after a dramatic election night which saw the SNP lose seats to the Conservatives, Labour and the Liberal Democrats.

Nicola Sturgeon's party lost 21 of the 56 constituencies it had won in 2015 and although the nationalists won the election in Scotland, the party saw both Mr Salmond and Angus Robertson, who had been depute leader and SNP leader at Westminster, lose out to the Tories.

Other high-profile losses included John Nicolson, Tasmina Ahmed-Sheikh and Mike Weir while in North East Fife Stephen Gethins held on to win by just two votes.

The Conservatives ended up with 13 MPs from north of the border, giving the party its best result in Scotland since 1983.

Ruth Davidson said her party had enjoyed an "historic night" and added: "Indyref2 is dead, that's what we have seen tonight."

Mr Swinney conceded it had been a "mixed night" for the SNP after Labour and the Liberal Democrats increased their tally of Scottish MPs to seven and four respectively.

He told BBC Radio Scotland's Good Morning Scotland: "We clearly have won the election but within that there are significant losses of seats and also the loss of some very significant individuals in our party from parliamentary activity, particularly my colleagues Angus Robertson, Alex Salmond and Mike Weir, these are three long-standing, significant figures in Scottish National Party politics."

While a number of factors had been at play in the vote, Mr Swinney said: "Clearly the focus on the message of saying no to a second independence referendum gained very significant traction.

"We saw that and we felt that."

He added: "As the First Minister has said in the early hours of this morning, we will take time and care to reflect on the outcome of this result, but we have to acknowledge that the question of a second independence referendum was a significant motivator of votes against the SNP in this election and we have to be attentive to that point.

"We're in the early moments of the aftermath of this election, we've got a lot to digest, a lot to think about.

"The SNP has emerged as the leading party in Scottish politics once again at Westminster, it's a significant feat for us to have achieved for the second election in succession, but there are clearly issues we have to address as a consequence."

Ms Sturgeon had earlier admitted she was "disappointed" by the results but said she would not make any "rash decisions" on her plan for another independence vote.

Meanwhile, the Tory success in Scotland came in stark contrast to the situation south of the border, where Theresa May lost her majority and the election resulted in a hung parliament.

The First Minister told BBC Scotland: ''This has been a disaster for Theresa May.

"She called an election clearly very arrogantly thinking she was going to crush the opposition, sweep everybody aside and cruise to a landslide majority.

''Her position, I think, is very, very difficult. We have to wait and see how things shake out. I've always said the SNP would want to be part of a progressive alternative to a Tory government.

''I'm disappointed at the SNP losses but I'm pleased that we've won the election.''

That was echoed by Mr Salmond, who said the SNP would now seek to "build a progressive alliance to take this country forward and to avoid the calamity of hard Brexit".

Tory Colin Clark, who defeated Mr Salmond in Gordon, said in his victory speech: "The silent majority have spoken. We're proud to be part of the United Kingdom."

Mr Salmond blamed a late surge in support for Jeremy Corbyn's Labour for the SNP's defeat in many seats.

Labour gained a number of seats back from the nationalists with the party making a return to winning ways in Scotland's largest city as they took Glasgow North East from Anne McLaughlin.

Ian Murray, who had been the only Labour MP in 2015, retained Edinburgh South with a massively increased majority as the party won a total of seven seats.

Scottish Labour leader Kezia Dugdale said she was "hugely encouraged" by the results.

"I think everybody had written us off and what we've got is six fantastic Labour MPs joining Ian Murray in the House of Commons, she said.

"I think it's very clear that any plan Nicola Sturgeon had for a second independence referendum has to disappear as a result of this election.

"What we've got is a crushing result for the SNP, they've lost 20 seats, if not more, and further than that they've watched their majorities crumble.

"There were so many SNP MPs who had 10,000 or larger majorities who now find they are sitting on perhaps a dozen or just under 100. That's a crushing result for the SNP.

"We've hit peak SNP and we've certainly hit peak Nicola Sturgeon."