John Bercow blew the whole thing apart. After years of petty sneers and active sabotages of parliament by the government, he finally took his revenge. And it was huge: dramatic, constitutionally-explosive and with far-reaching repercussions for Brexit and British democracy. Once he was done, the prime minister's strategy was in ruins.

This was a long time coming. The referendum had created a new kind of sovereignty in British democracy. Since the English civil war in the 1600s, sovereignty lay with parliament, which gained its legitimacy through the elections held by the public. But the referendum result created a new form of political legitimacy: that of direct democracy.

Theresa May used this every chance she got. She portrayed herself as the sole custodian of the people's will. What that will actually entailed changed almost daily. Once upon a time it opposed any transition. Now it supports both transition and an extension of Article 50. But this is what authoritarians always do when they mention the will of the people: they conflate it with their own.

With this political legitimacy behind her, she abused and ignored parliament. She tried to deny it a vote on triggering Article 50. She tried to rob it of any meaningful say on her deal. She stuffed the withdrawal bill full of statutory instruments allowing ministers to operate as mini-parliaments. She tried to block amendments to no-deal announcements. Instead of risking losing opposition day motions, she simply pretended they didn't exist and refused to participate in them. She ruled-out publishing government legal advice on the backstop and then, when parliament demanded she do so, tried to ignore it. She was found in contempt of parliament - a historic humiliation which in any other period would have triggered a prime ministerial resignation. She set a date for a vote on her deal, wasted days of parliamentary time debating it, then cancelled it when she thought she would lose. After that, she held it, was defeated, held it again, and was defeated once more. And then she decided she would have another go this week.

Throughout that process, the Speaker had urged her to treat parliament with more respect. He made the point time after time, especially when she delayed the vote on her deal. In return, government ministers accused him of being a double-agent for Remain. "He's made his views known on Brexit," leader of the House Andrea Leadsom said late last year. "It's a matter for him but nevertheless it's a challenge and all colleagues need to form their own view of that."

But today, as May was holding last-minute talks in a bid to get the DUP on side, Bercow kicked back. And he kicked back hard.

There is a section on page 397 of the parliamentary rule book Erskine May which states that "a motion or an amendment which is the same, in substance, as a question which has been decided during a session may not be brought forward again during that same session".

Speaking to constitutional experts this morning, not a single one predicted he would go down this route. Most thought that the rule allowed for a very wide interpretation of what the "substance" of the motion was. For instance, it was not just about whether the deal had changed. It would also consist, in the words of David Natzler, the clerk of the House, of the "underlying reality" of the situation. So if, through conversations with MPs, Bercow thought there was a shift of support towards the deal - and the weekend newspaper reports suggested there might be - he should allow another vote as the "substance" of the matter had changed.

Not so. Instead he blew the lid off the whole thing. "If the government wishes to bring forward a new proposition that is neither the same nor substantially the same" as last week's, he said, that would be in order. But "what the government cannot properly do is re-submit to the House the same proposition or substantially the same proposition as that which was rejected last week".

May had been allowed to hold her second vote because she had secured changes to it in the form of the joint interpretative instrument with the EU and a joint statement. But this time she hadn't even pretended to enter into talks with Brussels. The deal was the same. And therefore so was the motion. And therefore it was against the rules.

Bercow's analysis of what constituted the "substance" of a motion was much narrower than expected. The idea of a shift of MPs towards the deal clearly had no impact on him. And neither did he care much if the attorney general could be persuaded to say something new about the Vienna convention or the way the backstop operated. His test was whether something had changed in the deal itself.

That was pulverising. It destroyed the government's strategy. All May's parliamentary chickens had come home to roost. Her constant disrespect towards parliament, her attempts to bully it into submission, had triggered a counter-attack from the Speaker at the worst possible time. There is now basically no chance for her to hold another vote this week.

Westminster fell into chaos once again. And then, as the dust cleared, we were able to get a little more clarity on the options open to the prime minister.

The first - and Bercow heavily hinted that this was the best course of action - was for May to go the European Council meeting this week and secure changes.

There are two types available. Firstly, she can try and change the future relationship document - the non-legal part of the deal concerning the ultimate arrangements between the UK and EU. Brussels is willing to play with that part, although admittedly probably not to this timetable.

Secondly - and this will be far more tempting - she can ask for a two-option extension of Article 50, as per her motion last week. Option one is for a short technical extension if she gets her deal through parliament before March 29th. Option two is for a much longer extension of perhaps a year if she doesn't. She should, by virtue of having secured those extensions, be able to present her deal as substantially changed. But there is no certainty that the EU is prepared to allow a two-option extension.

There are other strategies. She can try to pass a motion on her deal which starts "notwithstanding the practice of the House" on repeat motions. This would allow her to get rid of the rule for this one endeavour. But the trouble here is that she would need a majority of MPs to support it and it is not clear that she could secure it. Several hardline Brexiter MPs were supporting Bercow on this today. Presumably many moderate Tory rebels would too. And Labour and other opposition parties would whip against it

She could try and skip the motion altogether and simply put forward her withdrawal bill, which would turn it into law. That would then act as the de-facto motion on whether the Commons backed her deal. But this is a very unwieldy way to proceed.

And finally there is the nuclear option, where she would basically switch parliament off and on again. This would involve crashing the session and putting forward a new Queen's Speech. That is dramatic and could have very far-reaching consequences. Some even think it could end up dragging the Queen into the dispute. May will be loath to try it and anyway probably cannot do so before March 29th.

Those are the options available to her. By far the easiest is to hope that an extension arrangement linked to the deal is a substantial enough change for Bercow to allow it. But it is now clear that, whatever she does, the Speaker is prepared to go way out on a limb to obstruct her if he disapproves. Her room to manouvre just significantly narrowed. And the extraordinary constitutional battle between the executive and parliament just reached a new and dramatic stage.

Ian Dunt is editor of Politics.co.uk and the author of Brexit: What The Hell Happens Now?

The opinions in Politics.co.uk's Comment and Analysis section are those of the author and are no reflection of the views of the website or its owners.