IT was the election no one wanted, in which the outcome was supposed to be a foregone conclusion. We can thank the sceptical British voter for upsetting Theresa May’s cunning plan. On the day she announced this snap election in April, I said there was a risk voters would feel they’d been taken for granted. Many clearly have felt that, though probably not strongly enough to deny May victory on Thursday.

There was no justification for this election, in defiance of the Conservative's own fixed-term parliament act, for which Theresa May voted in 2010. That was supposed to prevent unscrupulous prime ministers calling snap elections in order to exploit disruptive events or temporary weaknesses in the opposition. May said repeatedly that she was not going to call an early election because the country needed some stability in the run up to Brexit. She was right the first time.

She fought this election on her promise to be “strong and stable” and was soon revealed as weak and wobbly. Her performance in interviews, when it has not been evasive, has been robotic – like a not very bright student trying to remember her lines in an oral examination. Theresa May's place in British electoral history is assured not just because she squandered a 20-point lead, but because she U-turned on the key plank of her election manifesto in the middle of the campaign. Such was the dementia tax debacle – a wholly unforced error which arose because May did not understand her own policy on domiciliary care costs.

Theresa May has been winging it – hoping that by avoiding the TV debates and only appearing before selected audiences she could avoid being taken to task on her inability to articulate a clear policy agenda. She hoped that being tough on immigration would guarantee the votes of disillusioned Labour and Ukip supporters, but even that's come unstuck. The Brexit Secretary, David Davis, admitted on Question Time last week that the Government will not after all commit to cutting back immigration to 100,000 in the lifetime of the next parliament. Even he has realised that this would be economically disastrous and that Britain will need key workers whether we are in the EU or out.

The Conservatives also thought they could fall back on attacking Labour’s uncosted spending commitments, and recycle all those old “Tax Bombshell" election billboards. This backfired as soon as voters learned that the Tories had included no costings whatever in their manifesto – the only numbers were the page numbers. With the aid of obedient Tory newspapers, Theresa May then sought to exploit the Manchester suicide bombing by claiming Jeremy Corbyn had “blamed Britain” for the atrocity and had “excused terrorists” – neither of which allegation was true. He had echoed the observations made by MI5 and just about every informed commentator on terrorism, that episodes like the Iraq war had fuelled Islamist extremism.

Conservative commentators then dredged up old quotes from Corbyn about a united Ireland and accused him, falsely, of backing the IRA, not least in a doctored attack video. British voters rightly dismissed this smear. They saw, from his TV interviews, that far from being a raving, IRA-supporting extremist Jeremy Corbyn is more like a mild-mannered geography teacher. Many voters still don't rate him as a potential prime minister, but the Tory attempt at character assassination added to the sense that Theresa May was not playing straight with the British people.

For the Tory leader to be exposed in this way, in a campaign that was all about her personal integrity, was extremely damaging. It is not inconceivable that the final days of this election could see Theresa May's lead evaporate completely, though differential turnout will almost certainly win the day for the Conservatives. There has been a collapse in voter registration in this general election, particularly among the young who are overwhelmingly pro-Labour. I've been told of Scottish constituencies where 5,000 voters, mainly students, have fallen off the register.

This is unfortunate, because the country is already divided enough along age lines. If the Tories appear to win on the strength of the pro-Brexit over-60-year-olds, there will be understandable discontent – though younger people can hardly complain about not being represented if they don’t vote. The sooner we bring elections up to date the better. We do everything else online – shopping, banking, taxation – so why not voting?

It’s not that this election lacked interest or content. The standout was the success of the Labour manifesto, with its moderate left of centre policies. In truth, it was not hugely different from Ed Miliband's in 2015, and the SNP were justified in saying that it had borrowed a lot of their policies such as abolishing university tuition fees and scrapping hospital charges. But that is beside the point. It showed that the centre of gravity of politics has shifted markedly to the left in recent years. Labour should have won this election, and those Labour MPs who did their best to ruin Jeremy Corbyn's chances by bad-mouthing their own leader in the run up to 2017 will have a lot to answer for in the aftermath.

Assuming the polls are reliable, this election will leave us with the worst of all worlds: a Prime Minister whose authority has been fatally undermined going into the most difficult international negotiations that Britain has faced in the last half-century. We have learned precisely nothing about Theresa May's objectives in this Brexit process. She has fallen back on the irresponsible soundbite that “no deal with the European Union is better than a bad deal” without giving any clear idea of what a good deal would look like.

Does she seriously believe that Britain could walk away from the biggest free-trade area on the planet? Falling back on World Trade Organisation terms of trade would mean tariffs being placed on British exports and regulatory barriers placed on British services. The cost of this would dwarf 100 Corbyn spending pledges. Walking away from the EU negotiations would also mean the end of open skies, reciprocal health care and co-operation against terrorism. It would lead to a hard border in Northern Ireland and the departure of companies, like Standard Life and Nissan, who need to locate their operations in the EU in order to trade there.

These are vitally important issues that have had surprisingly little examination in an election campaign that was supposed to be all about Brexit. The SNP has found it extremely difficult, even in Scotland, to get voters concerned about the economic impact or the consequences for the Scottish Parliament of a hard Brexit. Instead, the dominant issue in Scotland has been the independence referendum, despite all attempts by SNP candidates to say that it isn’t.

The SNP campaign lacked focus. For the first time, Labour's agenda was significantly to the left of the Scottish National Party's despite Nicola Sturgeon's protestations that only her party was opposed to austerity and benefit cuts. Jeremy Corbyn's policies on taxation – both personal and corporate – outshone Sturgeon’s tepid proposal to introduce the 50p tax band that they had abandoned in Scotland in 2016. A lot of former Labour voters in the SNP camp were left wondering where their new party's radicalism had gone. Had it not been for the self-destructive behaviour of prominent Scottish Labour politicians like Ian Murray and Blair McDougall, who said Jeremy Corbyn wasn't fit to lead the party, the drift to Labour might have been greater.

In the event, the argument that only the SNP can counter the Tory revival in Scotland should be enough to shore up the leaks in Nicola Sturgeon's campaign, even though her personal popularity appears to have taken a knock, dropping 18 points in the opinion polls. The SNP leader may have suffered from the same entitlement issue as Theresa May. Many Scottish voters felt they had been taken for granted by the First Minister as she pressed ahead with plans for a second independence referendum. This year, everyone has been conscious of the scunner factor in Scottish politics: the widespread feeling among voters that they've simply had enough of referendums and elections, and want a bit of peace. The SNP is not immune to voter fatigue.

The Tories have clearly benefited from this in Scotland and on Friday morning viewers will be treated to something we haven’t seen for a very long time: large parts of the map of Scotland turning blue. Across the Borders, in the north-east, in Perthshire, the Conservatives will be returning MPs in significant numbers for the first time in 25 years. That may be what this election is be remembered for in Scotland, and not the fact that the SNP won again. Ruth Davidson will likely have the biggest smile on her face on Friday morning. And Nicola Sturgeon will have to think very carefully indeed about whether she still has sufficient public support to continue her crusade for an early independence referendum.