W HEN HISTORIANS come to write the tale of Britain’s attempts to leave the European Union, this week may be seen as the moment the country finally grasped the mess it was in. In the campaign, Leavers had promised voters that Brexit would be easy because Britain “holds all the cards”. This week Parliament was so scornful of the exit deal that Theresa May had spent two years negotiating and renegotiating in Brussels that MP s threw it out for a second time, by 149 votes—the fourth-biggest government defeat in modern parliamentary history. The next day MP s rejected what had once been her back-up plan of simply walking out without a deal. The prime minister has lost control. On Wednesday four cabinet ministers failed to back her in a crucial vote. Both main parties, long divided over Brexit, are seeing their factions splintering into ever-angrier sub-factions. And all this just two weeks before exit day.

Even by the chaotic standards of the three years since the referendum, the country is lost (see article). Mrs May boasted this week of “send[ing] a message to the whole world about the sort of country the United Kingdom will be”. She is not wrong: it is a laughing-stock. An unflappable place supposedly built on compromise and a stiff upper lip is consumed by accusations of treachery and betrayal. Yet the demolition of her plan offers Britain a chance to rethink its misguided approach to leaving the EU. Mrs May has made the worst of a bad job. This week’s chaos gives the country a shot at coming up with something better.

The immediate consequence of the rebellion in Westminster is that Brexit must be delayed. As we went to press, Parliament was to vote for an extension of the March 29th deadline. For its own sake the EU should agree. A no-deal Brexit would hurt Britain grievously, but it would also hurt the EU —and Ireland as grievously as Britain.

Mrs May’s plan is to hold yet another vote on her deal and to cudgel Brexiteers into supporting it by threatening them with a long extension that she says risks the cancellation of Brexit altogether. At the same time she will twist the arms of moderates by pointing out that a no-deal Brexit could still happen, because avoiding it depends on the agreement of the EU, which is losing patience. It is a desperate tactic from a prime minister who has lost her authority. It forces MP s to choose between options they find wretched when they are convinced that better alternatives are available. Even if it succeeds, it would deprive Britain of the stable, truly consenting majority that would serve as the foundation for the daunting series of votes needed to enact Brexit and for the even harder talks on the future relationship with the EU.

To overcome the impasse created by today’s divisions, Britain needs a long extension. The question is how to use it to forge that stable, consenting majority in Parliament and the country.

An increasingly popular answer is: get rid of Mrs May. The prime minister’s deal has flopped and her authority is shot. A growing number of Tories believe that a new leader with a new mandate could break the logjam (see article). Yet there is a high risk that Conservative Party members would install a replacement who takes the country towards an ultra-hard Brexit. What’s more, replacing Mrs May would do little to solve the riddle of how to put together a deal. The parties are fundamentally split. To believe that a new tenant in Downing Street could put them back together again and engineer a majority is to believe the Brexiteers’ fantasy that theirs is a brilliant project that is merely being badly executed.

Calls for a general election are equally misguided. The country is as divided as the parties. Britain could go through its fourth poll in as many years only to end up where it started. Tory MP s might fall into line if they had been elected on a manifesto promising to enact the deal. But would the Conservatives really go into an election based on Mrs May’s scheme, which has twice been given a drubbing by MP s and was described this week even by one supportive Tory MP as “the best turd that we have”? It does not have the ring of a successful campaign.

To break the logjam, Mrs May needs to do two things. The first is to consult Parliament, in a series of indicative votes that will reveal what form of Brexit can command a majority. The second is to call a referendum to make that choice legitimate. Today every faction sticks to its red lines, claiming to be speaking for the people. Only this combination can put those arguments to rest.

Take these steps in turn. Despite the gridlock, the outlines of a parliamentary compromise are visible. Labour wants permanent membership of the EU’ s customs union, which is a bit closer to the EU than Mrs May’s deal. Alternatively, MP s may favour a Norway-style set-up—which this newspaper has argued for and would keep Britain in the single market. The EU is open to both. Only if Mrs May cannot establish a consensus should she return to her own much-criticised plan.

Getting votes for these or any other approach would require thinking beyond party lines. That does not come naturally in Britain’s adversarial, majoritarian politics. But the whipping system is breaking down. Party structures are fraying. Breakaway groups and parties-within-parties are forming on both sides of the Commons, and across it. Offering MP s free votes could foster cross-party support for a new approach.

The second step is a confirmatory referendum. Brexit requires Britain to trade off going its own way with maintaining profitable ties with the EU . Any new Brexit plan that Parliament concocts will inevitably demand compromises that disappoint many, perhaps most, voters. Mrs May and other critics argue that holding another referendum would be undemocratic (never mind that Mrs May is prepared to ask MP s to vote on her deal a third or even fourth time). But the original referendum campaign utterly failed to capture the complexities of Brexit. The truly undemocratic course would be to deny voters the chance to vouch that, yes, they are content with how it has turned out.