THERESA MAY called a snap election two months ago to build a “strong and stable” government. How those words will haunt her. On June 8th voters decided that, rather than transform her small majority into a thumping one, they would remove it altogether. The result is a country in an even deeper mess. Mrs May is gravely wounded but staggering on. If and when she goes, yet another election may follow—and its plausible winner would be Jeremy Corbyn, of Labour’s far-left fringe. On the eve of the Brexit referendum’s first anniversary, the chaos it has unleashed rumbles on unabated.

With negotiations due to begin in Brussels in days, the circumstances could hardly be less promising. Yet the electoral upset has thrown up a chance for Britain and the European Union to forge a better deal than the one which looked likely a week ago. Because Mrs May’s drastic “hard Brexit” has been rejected by voters, the question of what replaces it is back in play.

That rejection has at least made clear what Brexit does not mean (see article). Mrs May planned both to end the free movement of people between Britain and the EU and to slash overall net migration by nearly two-thirds. She ruled out membership of the single market and customs union. Worst of all was her dictum that “no deal is better than a bad deal”, which threatened to crash Britain out of the EU if Brussels failed to make a good enough offer. Many factors were to blame for the Tories’ failure, not least an insipid campaign. But big boosts for Labour in Remain-voting areas suggest that Brexit motivated many; we calculate that it was responsible for about half the Tory swing to Labour (see article). Mrs May beseeched voters to endorse her extreme approach. Voters have delivered their verdict and it is damning.

Since the government lacks a majority, deciding what Brexit means will fall to Parliament, as it always should have done. The close election merely underlines the need to find an approach that reflects the close referendum. Moderate Tories, including Philip Hammond, the chancellor, and Ruth Davidson, who led the party to success in Scotland, are speaking up for an exit that keeps Britain open to trade and migration—provoking fury among some hardline Brexiteers. Others are mellowing for fear of losing their seats, following the loss of solid Tory constituencies like Kensington.

The Democratic Unionists, a Northern Irish party on which the government will depend in key votes, want to minimise problems at the border with the republic, which may mean staying in the customs union. The business lobby, previously frozen out by Mrs May along with everyone else, is arguing for a softer exit, too. The upheaval empowers civil servants, who privately favour the least-disruptive Brexit possible.

Negotiations will be hamstrung by the government’s precariousness. The talks will last until late 2018, perhaps beyond Mrs May’s sell-by date. So Britain needs to reach a cross-party agreement on the basic principles of Brexit, and then find a way to make the consensus stick, whoever is in power. Several senior Tories, as well as the Liberal Democrats, have proposed a commission to draw up a negotiating mandate, rather as the EU government have for the European Commission. The main obstacle is Labour, which sees no reason to make life easier for the Tories. Yet such a commission may be in its interest. Nailing down the principles of Brexit now would save it from having the argument later in office; Mr Corbyn, who has never shown much interest in the subject, would be free to focus on his revolution at home.

The EU can improve the chances of a sensible outcome. It does not want Britain to emerge with a better deal than it had as a member, in case that gives ideas to Eurosceptics in other countries. But the risk of anyone envying Britain in its current lunatic state is slight. The EU should recognise that there remains a grave risk of “no deal”, and do what it can to avert that outcome, which would be catastrophic for Britain and very bad for everyone else. There have been encouraging comments from Emmanuel Macron, France’s president, and Wolfgang Schäuble, Germany’s finance minister, that Britain would be welcome back if Brexit were reversed. But that is still unlikely; the focus should be on limiting Brexit’s damage.

Meeting half way

Reaching a good deal will require time. So both sides should agree on a long transition, in which Britain lives under today’s terms until a trade agreement is struck. It will also require flexibility. The issue most likely to scupper a mutually beneficial deal is freedom of movement. Britain cannot expect special treatment, but offering it a minor get-out, of the sort already enjoyed by countries such as Norway and Switzerland, would allow a better single-market deal for all. If European leaders refuse any compromise, they will make their own citizens poorer. That is no way to build support for the principle of free movement.

Britain’s position is appallingly weak. The negotiations are as likely as ever to blow up before they get going. But the chaos in Westminster presents a rare opportunity to change the course of Brexit. Both sides should seize it.