The First Minister of Scotland. Scottish Government / Flickr. Some rights reserved.

One of the major surprises from last night’s general election was the SNP's fall from grace. In 2015 Nicola Sturgeon's party dominated the election in Scotland by winning 56 seats out of a possible 59. Only two years later, however, and this was reduced to 34 seats. The party also lost two of their biggest names in Westminster – depute leader of the party Angus Robertson and former first minister Alex Salmond.

What lies behind these changing fortunes? Here are five important factors:

1. The election was fought on very different grounds in Scotland

Both the Conservatives and Scottish Labour chose to make the election about a second independence referendum, despite the Scottish Parliament already voting in favour of this in March this year. While the the SNP won nearly all available seats in 2015, this was largely because the pro-independence vote rallied behind one party, whereas the Unionist vote was split three ways between Labour, the Conservatives and the Liberal Democrats.

In reality, such a large proportion of SNP MPs was never really representative of the country, and the only direction the SNP could go in this election was downwards. This time pro-Union voters were more strategic, and backed the candidate that was best placed to beat the SNP. In many instances this was the Conservative candidate, as the party has successfully positioned itself as the most strident defender of the Union under the leadership of Ruth Davidson.

2. The Conservatives had everything to gain and nothing to lose... and a lot of mysterious money

Before the election the Conservatives only had one MP in Scotland, and so could only hope to improve on their previous showing. Ruth Davidson ran a very good campaign and has proven herself to be a capable and effective leader. However, as openDemocracy revealed last week, there is another factor at play. Conservative election spending in Scotland has more than trebled in five years, and it is unclear who is bankrolling it. Households in Scotland are being flooded with Conservative propaganda in a way they never have never been before.

However, despite the Scottish "Tory surge", Davidson’s party still only won 29% of the vote, compared with 46% in England. While the Scottish Conservative vote is still significantly lower than in England, it was still enough to secure 13 seats.

The result is that the new landscape of MPs in Scotland more accurately reflects the politics of the country. However, this by no means signals the end of the SNP – Nicola Sturgeon’s party still won the election, taking more seats than all the other parties combined.

3. The SNP became complacent

Nicola Sturgeon’s demand for a second independence referendum after the Brexit vote was poorly timed and did not go down well in some parts of the country. Many people who supported independence and voted SNP did so because they wanted to create a more progressive society. But the SNP have failed to live up to this – their programme in government has been underwhelming and their manifesto for the general election was lacklustre.

Faced with a more radical Corbyn-led Labour party, they were outflanked to the left and could no longer claim the moral high ground as they have been able to in the past. Despite Scottish Labour's attempts to distance themselves from Corbyn, and even undermine him, Corbyn's message and manifesto still cut through. This is to the great credit of Jeremy Corbyn and his effective election campaign.

4. There is limited loyalty to the SNP on the left

One of the most dynamic parts of the Scottish electorate is the roughly 10% of voters who sit to the left of the SNP. This group tends to vote on the basis of progressive policy potential rather than party loyalty. In the 1999 Holyrood elections this group voted Labour, and then went on to deliver 7 Green MSPs and 6 Scottish Socialist Party (SSP) MSPs in the 2003 election. In 2007 and 2011 they mainly backed the SNP, before flirting with the Greens again in 2016.

Generally speaking, this group of people voted Yes in the 2014 independence referendum because they saw it as a left-wing option. However, they have little affinity or loyalty to the SNP or its leader.

It is likely that Jeremy Corbyn’s unashamedly social democratic manifesto was a major draw for these voters, and some of them may have voted for Labour at the expense of the SNP.

5. The Brexit factor

It is often forgotten that a third of SNP voters backed Brexit in the EU referendum last year. While official data has yet to be released, it is possible that some of these people abandoned the SNP in order to vote for a party that was more committed to Brexit, such as the Conservatives, or, potentially, Labour. Whether or not this diminishes their support for Scottish independence remains to be seen.