In one of her very first acts as SNP leader, Nicola Sturgeon made an extraordinarily generous attempt to get the UK government out of a pickle of their own making. She pointed out that the EU referendum need pose no threat at all to the unity of Britain if a Swiss-style "double majority" system was used, ensuring that all four constituent nations of the UK would have to vote Leave before the decision could be considered valid.

The reward for her constructive proposal was a chorus of derision. How dare this provincial non-entity imply that Scotland with its paltry 8% of the population should be able to dictate to the other 92%? Pah! We make decisions as a glorious United Kingdom, and every vote is equal, no matter what that jumped-up parish council leader might think!

Well, that's absolutely fine – or almost fine, anyway. The only very minor snag with these high-minded democratic principles is that they just happen to be totally at variance with the solemn pledge made to Scottish voters during the independence referendum in 2014. The electorate was informed in no uncertain terms by the Conservatives, Labour and the Liberal Democrats that a Yes vote would lead to Scotland being banished from the European Union, but that a No vote could guarantee that Scotland would be kept safely within the club.

It's up to those three parties to explain how they can possibly make good on that guarantee now that a UK-wide referendum leaves Scotland on the brink of being dragged out of the EU against its will. OK, they clearly didn't care much for Ms Sturgeon's solution, and that's their prerogative, but they will naturally have to come up with one of their own instead – and to put it mildly, time is running out. All the SNP could ever do was advise and offer helpful suggestions, but ultimately this is London's predicament to resolve.

It goes without saying that the one and only 'solution' David Cameron has vaguely had in mind is simply to wait for the problem to go away. After all, this was supposed to be the referendum he couldn't lose – a cosmetic renegotiation coupled with warnings of economic apocalypse was just the recipe to get Eurosceptic voters from the English shires dutifully scurrying back towards Remain.

It's still possible, and arguably likely, that the strategy will pay off at the very last minute. But with the polls pointing to a virtually tied race, it's reasonable to at least begin to entertain the possibility that the unthinkable might just be about to unfold. If it does, the vote against independence two years ago will have been indisputably won on a bogus premise, and the case for reopening Scotland's own constitutional debate will be unanswerable.

Make no mistake – if Nicola Sturgeon decides to pull the trigger, the Scottish Parliament will vote in favour of holding a second independence referendum. The two main pro-independence parties (the SNP and the Scottish Greens) won a clear majority of seats at last month's election, and Green co-leader Patrick Harvie subsequently confirmed that his party would back another referendum if they were asked to do so in the event of Brexit. Even if the Greens change their minds for some reason and abstain instead, the motion will still pass by 63 votes to 59. It's unthinkable that a pro-independence party would actively vote a referendum down, so anyone in the London establishment who imagines that the whole issue might be quietly snuffed out on the floor of the Scottish Parliament should stop dreaming now.

Stephen Gethins
Stephen Gethins, seen here with Nicola Sturgeon, backs the SNP leader to make a strong case to remain Getty

But could the UK government do the snuffing out themselves? It remains an open question whether there is a viable legal path for Scotland to hold an independence referendum without London's "permission". The renowned legal expert Professor Robert Black has stated that a carefully-worded consultative referendum question would be entirely within the Scottish Parliament's current powers. Others disagree, but that ambiguity offers the SNP the opportunity of a pretty straightforward 'each-way bet'. If a referendum bill were to fail to make it past the legal hurdle in spite of their best efforts, they could simply challenge London to respect the clearly-expressed wishes of Scotland's democratically elected legislature, and remove the impediment. That wouldn't be easy to ignore after the events of the last few weeks.

It's probably safe to assume that, just as Alex Salmond's every use of the phrase "once in a generation event" was lovingly recorded by his opponents for future use, the SNP will have been returning the compliment by documenting every example of Remain campaigners exploiting the Scottish issue for their own advantage. David Cameron, Tony Blair and John Major have all issued vocal warnings to English voters that the SNP would respond to Brexit by holding a second independence vote, and that a Leave vote therefore puts the future of the UK in jeopardy. It'll be a tad difficult to argue further down the road that it is somehow illegitimate for Nicola Sturgeon to act in exactly the way it was warned she would act, especially given that her casus belli is so watertight. Apart from anything else, wouldn't that mean the warnings were a giant con-trick perpetrated against the English?

Perhaps the UK government are consoling themselves with the thought that, even if an independence referendum proves unavoidable, the Scottish people may vote No again and leave the SNP with nowhere to go. That's possible – polls have so far tended to suggest that a Leave victory would only make independence a little more popular. But any complacency on that score ought to be dispelled by the remarkable admission from the anti-independence newspaper The Herald that Brexit could well turn its own constitutional stance upside down. If that's an early sign that previously reliable opinion-formers will turn against the union, small 'c' conservative voters who weren't even giving the Yes campaign a hearing in 2014 may soon be open to persuasion – not least because independence could start to look like the only credible method of retaining EU citizenship.

And even if independence is ultimately rejected by the electorate again, there's simply no such thing as the status quo for Scotland in the event of Brexit. Because of the way the devolution settlement works, with any powers that are not specifically reserved to Westminster deemed to be automatically devolved, a withdrawal from the EU would lead to enormous powers being repatriated to the Scottish Parliament at a stroke.

If Westminster wanted to reimpose some kind of central control over agriculture and fisheries, the only way to do it would be to breach the hitherto sacrosanct Sewel convention, which states that the UK parliament can only legislate on devolved matters with explicit consent from Holyrood. That kind of arrogant disregard for the rule-book might have been feasible once upon a time, but in the post-2014 world it would inevitably spark a major constitutional crisis. At best, the Scottish Government might be persuaded to take part in negotiations to resolve any dispute, but they would be sure to extract a heavy price for accepting even the most limited encroachment on their rightful powers.

Now, of course, all of these possibilities are merely 'what ifs'. All of them will be instantly closed off if there is any sort of Remain majority across the UK. Surprising as it may seem, that's precisely the referendum outcome that the SNP leadership and most independence supporters are genuinely praying for, mostly because they are so afraid of what a right-wing London government might do without the EU to hold it back.

It's ironic that the result the SNP are pulling out all the stops to avoid could easily prove to be the ultimate "heads I win, tails you lose" scenario, either leading directly to independence itself, or else to Whitehall's second-worst nightmare – the belated and accidental delivery of that old mirth-inducing promise that Holyrood will become "one of the most powerful devolved parliaments in the world".

James Kelly is author of the Scottish pro-independence blog, SCOT goes POP! Voted one of the UK's top political bloggers, you can hear more from James on Twitter: @JamesKelly