Frustrated European leaders abandoned hope Thursday that Britain would sort its departure from the European Union anytime soon, slapping aside a proposal by Prime Minister Theresa May for a short delay and offering to extend Brexit until Halloween.

The decision avoids a chaotic departure by Britain on Friday. It also might lock Britain into elections for the European Parliament next month — which would increase agitation for May’s resignation.

May wanted an extension to June 30 to seal a deal with her own divided lawmakers. The European leaders, talking Brexit for at least the 18th time and exasperated by Brexit “emergency summits,” wanted to free themselves from the chaos of British politics. 

The Oct. 31 extension could end early if British lawmakers sign on to the E.U.’s unpopular terms of departure. Leaders also said they would review the membership in June.

The extension is “long enough to allow the U.K. to find a solution,” said European Council President Donald Tusk. “I have a message to our British friends. Please, do not waste this time.”

At the summit on Wednesday, May was peppered with 45 minutes of questions by European leaders. They demanded to know her political strategy. They were openly skeptical that her negotiations back home with the opposition Labour Party would produce a winning compromise. They extracted commitments of good behavior if Britain remains an E.U. member.

Then her counterparts ushered her out so they could trade views about just how harsh they wanted to be. They debated while eating a dinner of warm scallop salad, loin of cod with brown shrimp and mini mushroom arancini. They continued arguing into the Brussels night as May cooled her heels at the residence of the British ambassador to the European Union. Finally, they called her back to deliver their offer.

Even the reprieve was the result of a compromise among the European leaders, with French President Emmanuel Macron favoring harsher terms that could have cut Britain loose sooner, and others favoring a softer touch.

“For me and for Germany it was clear, that Germany would fight for an orderly exit,” German Chancellor Angela Merkel said afterward at a news conference. “Not because of British demands but for our own interest.” She left the door open to more extensions.

Because May has failed to get Parliament to approve the withdrawal deal she negotiated for two years with the E.U. — her own party members loathe it and vote against it at every opportunity — Britain finds itself in limbo.

It will stay in the club — and is still on the hook for membership dues — but its voice will be muffled. British members of the European Parliament might make some mischief, as threatened by hard-line Brexiteers, but London will have little sway in Brussels. Tusk said May promised that the British wouldn’t make too much trouble.

“I know that there is huge frustration from many people that I had to request this extension,” May said after the summit’s conclusion. “The U.K. should have left the E.U. by now, and I sincerely regret the fact that I have not yet been able to persuade Parliament to approve a deal which would allow the U.K. to leave in a smooth and orderly way.”

She ducked repeated questions from reporters about whether she would stay on as prime minister if Britain is still in the E.U. after June 30, saying that she can deliver Brexit before then.

European leaders stressed that they will not reopen the withdrawal agreement itself, which covers the payouts and terms of the divorce.

Nor will they budge on a guarantee to keep the Irish border open and mostly invisible.

And no future trade deal between the U.K. and E.U. will be negotiated until the withdrawal deal is inked, the Europeans say.

Those restrictions — which give stomach cramps to many British lawmakers — are nearly unavoidable, E.U. diplomats said. Even if Britain declares it wants to leave without a deal, the next demand from the Europeans will focus on the core of what British already agreed upon: cash, the Irish border and the rights of E.U. citizens in the U.K.

“It is now up to the British to be honest with themselves and with their people,” Macron said.

May said talks with the Labour Party would continue Thursday. The hope is to come up with a vision of Britain’s future relationship with the E.U. that might win over the divided House of Commons.

But those talks have yet to produce any breakthroughs. Both Labour and Conservative leaders described the negotiations as “productive,” but opposition negotiators have complained that May was not moving far from her red lines.

E.U. diplomats said those talks barely figured into their planning — because they don’t expect much to come of them.

Meanwhile, May’s own party is divided and her cabinet is mutinous — filled with ministers who want her job.

Britain was originally supposed to leave the E.U. on March 29. Hardcore Brexiteers are furious at the idea of yet another delay — and at the idea that the country is preparing for European Parliament elections nearly three years after voting to leave Europe. They say they are willing to see Britain break away with no deal, no transition period, no safety net. 

But the International Monetary Fund warned Tuesday that a no-deal Brexit could lead to a two-year recession for Britain. And European leaders were in no mood to invite that sort of economic or political instability.

October is just long enough to relieve pressure on British lawmakers for a quick compromise. But it may not be enough time to allow May — or her successor — to pursue a truly new approach, such as a new referendum. Some diplomats who favored a longer extension expressed concern that the compromise could raise the risk of sending the British talks aground.

Despite the seriousness of the meeting, there appeared to be less tension than at a summit last month, when May had several icy exchanges with leaders as they sat down to discuss Britain’s fate, including a chilly double-cheek peck with European Commission President Jean-Claude Juncker of Luxembourg. 

On Wednesday, May shared uproarious laughter with Merkel after the German leader showed her what a diplomat who was clued in on the joke — and who spoke on the condition of anonymity because diplomats aren’t allowed to be funny on the record — said were pictures of the two leaders speaking to their parliaments earlier in the day wearing similar blue jackets. 

In the coming months, the E.U. will replace its full slate of senior Brussels officials and begin talking about a new multiyear budget, areas where an adversarial Britain could stir up trouble. The date picked for the final goodbye, Oct. 31, is also the last day the current European commissioners are expected to serve in their jobs.

Quentin Ariès contributed to this report.