The General Election of 2017 will go down in history as one of the great political upsets of our time, and a warning to all those who would seek to exploit people's fears and turn them to their own advantage.

Theresa May thought she could leverage widespread insecurity over Brexit to inflate her majority, crush democratic opposition, and impose another five years of austerity on communities across the UK. Instead, she has lost her majority, her credibility, and the support of her own party.

Meanwhile, in Scotland, Nicola Sturgeon has repeatedly shown her willingness to sacrifice anything and everything in pursuit of her ultimate goal of independence – including her own personal integrity. She thought this election provided her with the ideal opportunity to drive another wedge between Scotland and the UK. She was wrong.

Yesterday, both of these stratagems, arrogant in conception and cynical in intent, were fulsomely rejected at the ballot box.

So confident was Theresa May of securing an increased majority that she thought she could ram any old manifesto down the throats of the electorate, no matter how miserly and devoid of hope.

But millions of people said no to the dementia tax, no to hard Brexit, and no to tax breaks for the wealthy and economic pain for everybody else.

Instead, they embraced a Labour vision that offered hope and solace to the old, the young and the vulnerable; a vision animated by compassion and optimism in equal measure.

Labour wants to preserve all that is best about our society and build a better future for the many, not just the few.

Contrary to tawdry Tory smears, our vision is no idle pipedream – Labour's manifesto was the only fully-costed political prospectus produced by any of the major parties at this election.

We told voters what we were going to do, and we told them how we were going to pay for it. We were open, honest and ambitious and the electorate responded to that.

It is to the SNP's eternal shame that thousands of Scots felt that another five years of Tory incompetence was the only way to fend off the threat of another unwanted and unnecessary independence referendum. We said that the SNP's constitutional obsession risked letting the Tories in by the back door, and so it has proved.

I know from my own experience on the doorstep how concerned people were about Scottish independence, and how conflicted they felt about the choices available to them. In my own constituency of Edinburgh South, it was a straight fight between Labour and the SNP, and voters were able to reject independence and Tory austerity by voting for me. They did so in their droves – my majority, just over 300 in 2010, has now swelled to over 15,000.

Theresa May's credibility is in tatters, and her mandate for a hard Brexit has been utterly undermined.

At this election, we had an opportunity to kick the Tories out of government, and negotiate a Brexit deal that will protect jobs and livelihoods, and preserve our free and unfettered access to the single market. Thanks to the SNP, that opportunity has been missed.

That said, the fight isn't over, and further opportunities may soon present themselves. Theresa May's credibility is in tatters, and her mandate for a hard Brexit has been utterly undermined. Labour MPs across the UK will come together to hold the Tories to account, and thwart their bleak, austerity-laden vision for the future of our country.

Meanwhile, in Scotland, it is clear that Labour's fortunes are on the up, and the SNP's are on the wane. Two years after losing all but one of our seats in Scotland, we have defied the pollsters, who wrote us off in this campaign, to claim a clutch of crucial seats –pushing the SNP agonisingly close in others – and send a talented cohort of Scottish Labour MPs to Westminster.

On Friday, for millions of voters across the UK, solidarity triumphed over division, and hope trumped austerity. We aren't quite where we want to be, but we are a lot closer than we were.

Ian Murray is Member of Parliament for Edinburgh South