LONDON — Britain’s Parliament delivered a crushing defeat to Prime Minister Theresa May’s European Union divorce deal Tuesday, plunging the Brexit process into chaos just 17 days before the U.K. is due to leave the bloc.

Lawmakers rejected the deal 391-242, ignoring May’s entreaties to back the agreement and end the political chaos and economic uncertainty that Brexit has unleashed.

It was a narrower outcome than the 230-vote margin of defeat for the agreement in January, before May secured changes from the bloc — but not by much.

With EU leaders warning there would be no more changes or negotiations, and with less than three weeks to go until the U.K. is due to leave, British lawmakers now face a stark choice between leaving the EU without an agreement to smooth the way, or delaying the country’s withdrawal past the scheduled March 29 departure date.

May — her voice ragged after days of frantic shuttle diplomacy to secure last-minute changes to the deal — had earlier told the House of Commons, “this is the moment and this is the time — time for us to come together, back this motion and get the deal done.”

“If this deal is not passed, then Brexit could be lost,” May said.

But prominent Brexit supporters whose support May needs were unconvinced. Hard-core Brexit supporters in May’s Conservative Party and the prime minister’s allies in Northern Ireland’s Democratic Unionist Party both said they could not support the deal, which Parliament rejected by an overwhelming margin in January.

The DUP, which props up May’s minority government, said “sufficient progress has not been achieved” on the key issue of the Irish border.

The European Research Group of pro-Brexit Conservatives, which has dozens of lawmakers as members, said the amendments “do not deliver ‘legally binding changes'” to the withdrawal agreement, as the government promised.

“In light of our own legal analysis and others, we do not recommend accepting the government’s motion today,” group member Bill Cash said.

At a late-night news conference Monday in Strasbourg, France, May and European Commission President Jean-Claude Juncker announced changes designed to overcome lawmakers’ concerns about provisions designed to ensure the border between EU member Ireland and Britain’s Northern Ireland remains open after Brexit.

The mechanism, known as the backstop, is a safeguard that would keep the U.K. in a customs union with the EU until a permanent new trading relationship is in place. Brexit supporters in Britain fear the backstop could be used to bind the country to EU regulations indefinitely.

May said documents to be added to the deal provided “legally binding” assurances that the backstop would be temporary and that Britain would have a way to get out of it if the EU failed to negotiate in good faith. However, the text of the 585-page withdrawal agreement remained unchanged.

May hoped the changes would be enough to overturn the 230-vote margin of defeat for the deal in January.

But her hopes were dashed when Attorney General Geoffrey Cox said the changes “reduce the risk” Britain could be trapped inside EU regulations — but do not eliminate it. The two-page opinion said the U.K. could still not extract itself from the terms of the divorce deal unilaterally, a key demand of pro-Brexit British politicians.

In a written legal opinion , Cox said that if U.K.-EU negotiations became stalled through “intractable differences,” Britain would have “no internationally lawful means of exiting the Protocol’s arrangements, save by agreement.”

John Whittingdale, a Brexit-supporting Conservative lawmaker, said the attorney general’s advice was “pretty terminal” for May’s plan.

The main opposition Labour Party also said it would reject the deal.

“In terms of the substance, literally nothing has changed,” Labour leader Jeremy Corbyn said.

The pound, which had risen on hopes the deal would be passed, slumped by more than 1 percent against the dollar after Cox’s assessment, to trade at $1.3108.

Other EU nations had urged British politicians to seize the chance to back the deal and ensure an orderly departure.

German EU affairs minister Michael Roth, called it “a far-reaching compromise.” Dutch Prime Minister Mark Rutte tweeted that he was “pleased with the agreement,” adding: “An orderly #Brexit is crucial for both the EU and the UK. There is no alternative.”

The EU warned British politicians that negotiations will not be reopened if Parliament rejects the deal again.

“In politics, sometimes you get a second chance. It is what you do with this second chance that counts. Because there will be no third chance,” Juncker said.

Britain’s political impasse over Brexit has raised fears of a chaotic “no-deal” Brexit that could mean major disruption for businesses and people in the U.K. and the 27 remaining EU countries, with tariffs and border checks imposed on trade between the two.

Lawmakers are now due to vote in the next two days on whether to leave the EU without an agreement — an idea likely to be rejected — or to ask the EU to delay Brexit.

Delaying Brexit would need the approval from all 27 remaining EU countries. They are likely to agree, as long as Britain leaves before elections to the European parliament in late May.

Some British lawmakers had warned their Brexit-backing colleagues that rejecting the deal could lead to Britain’s departure being postponed indefinitely, because a delay would give momentum to opponents of Brexit.

“Today is our Hotel California moment. If we don’t check out tonight, we may never leave,” tweeted Conservative legislator Bob Seely.

More than two and a half years after the country voted to leave the EU — and with no certainty about when or how it will — many Britons are simply fed up.

In the staunchly pro-Brexit port of Dover in southern England, retiree Mary Simpson said she felt that her voice as a “leave” voter had not been heard.

“I am actually considering never voting again, quite honestly, because I am beginning to feel that there is no point in it,” she said.

Associated Press writers Raf Casert in Strasbourg, France, Pan Pylas in London and Renee Graham in Dover, England contributed.