THE SNP's loss of 21 seats represents a dramatic fall from grace for a party that just a few months ago seemed invincible with a vice like grip on Scottish politics.

Defeats for Alex Salmond and Angus Robertson brutally illustrate a swift decline in the party's fortunes from the 2015 election and one of its greatest ever triumphs when it took 56 of Scotland's 59 seats at Westminster.

Despite the SNP remaining Scotland's biggest party at Westminster, something it's spokespeople are keen to remind us of, there can be little doubt that the loss of over a third of its MPs is a chastening result.

The loss of SNP big beasts Salmond, the politician who first led the party to power a decade ago, and Robertson, who masterminded its election campaigns in 2007 and 2011, will burn away at the psyche of supporters for some time.

But it's the implications the losses have for Nicola Sturgeon's plans for a second independence referendum that loom large above all else.

The ongoing uncertainty surrounding Brexit means that an independence referendum will remain an option and could become very real again if the process of EU withdrawal becomes chaotic. Nicola Sturgeon may therefore decide to focus on the substantial issue of the UK's Brexit talks, as her first priority, rather than the more distant likelihood of a second independence referendum.

However unpalatable it is for supporters of independence to accept, the loss of 21 seats to parties that aggressively campaigned against 'indyref2' severely weakens the case for a referendum in the next few years.

Any suggestions that the setback makes little difference will ring hollow with many voters.

The most frank admission of this reality came from John Swinney who said that the plans for a second independence referendum was a motivating force against the SNP that had gained "significant traction" in the election.

Sturgeon too has said she will "reflect" on the result and also admitted the referendum demand was a factor in the election result.

Swinney's suggestion that the prospect of a second referendum galvanised Unionist voters and left the SNP vulnerable to losses in areas with a high No vote in 2014 seems plausible as an explanation for the party's electoral reverse.

It's a line of attack that played well in middle class parts of Aberdeenshire and Perthshire, that until last week had not elected Tory MPs since the early 1990s.

But there was also seemingly a failure by the SNP campaign to spot a potential Labour mini-revival in Scotland, via a 'Jeremy Corbyn bounce' rather than any efforts by Kezia Dugdale.

The prospect of Labour's gains in working class seats it won - such as Rutherglen & Hamilton West; Kirkcaldy & Cowdenbeath; Glasgow North East; Coatbridge, Chryston & Bellshill; and Midlothian - were seemingly not on the SNP's radar.

Labour was only expected to be in contention in Edinburgh South, the sole Scottish seat it won in 2015, and in East Lothian - the other two constituencies it took.

Senior SNP figures made clear that success for the party on June 8 would strengthen the mandate the party says it secured at the 2016 Holyrood election.

But given the outcome, even with a disastrous Brexit process, it's questionable whether Sturgeon could call an independence referendum without winning a fresh mandate from the electorate - probably at the 2021 Holyrood elections.

Again what many in the the SNP will find so hard to come to terms with is how quickly the party's hitherto unchallenged dominance of Scottish politics has been eroded.

For many observers, particularly since 2011, it has appeared the usual laws of politics did not apply to the SNP with the party enjoying unprecedented popularity despite a mixed record over policy areas such as school attainment and the NHS.

What's striking though about this election is that it's the first one the SNP has suffered any significant electoral setback since its ascent to power in 2007.

True, the party has nearly four years left to serve of its current term in government at Holyrood and remains well placed to win a fourth term, but there's now a feeling that the SNP has become stale in power, with the decisive victories the party enjoyed in 2011 and 2015 even now seeming like a distant memory.

It was this staleness that partly characterised the SNP's General Election campaign, with the party at times struggling to articulate a 'Plan B' when things did not go according to script.

A failure by the party to turn hostility towards Brexit into support for independence, and to use it to also prevent a surge in Tory support, stands out as strategic problems.

The SNP also sought to change tack late in the election campaign by offering to help prop up a minority Labour government.

Nicola Sturgeon's pitch to voters to back the SNP as the best way to aide Jeremy Corbyn and defeat the Tories was a departure from the early stages of the campaign when the First Minister dismissed the Labour leader's prospects of success.

This contrasted to the 2015 General Election when Sturgeon and the SNP had a message from the start of the campaign that the SNP would help "lock out" the Tories from 10 Downing Street".

Talk of an anti-austerity alliance with Corbyn, Plaid Cymru and the Greens from the moment the 2017 election was called may have served the party better this time.

However, it is cooperation with other anti-austerity parties at Westminster that could yet hold out the best hope for the SNP.

It's worth remembering that at the 2010 General Election, the LibDems came into the coalition government, having lost seats.

Ironically it's possible that despite having a smaller number of MPs the SNP could also become more influential at Westminster if any Tory-led government were to collapse.

It's also worth pointing out that the SNP remains the third biggest party at Westminster despite its diminished status and the loss of figures such as Robertson and Salmond.

So while it's now seems the chance of an imminent independence referendum has drastically diminished, the SNP remains a hugely powerful force and could recover sooner than its opponents expect.