LONDON (AP) — In a hard-won victory, British Prime Minister Theresa May persuaded her fractious Cabinet to back a draft divorce agreement with the European Union on Thursday, a decision that triggers the final steps on the long and rocky road to Brexit.

But she faces a backlash from her many political opponents and a fierce battle to get the deal through Parliament as she tries to orchestrate the U.K.’s orderly exit from the EU.

May hailed the Cabinet decision as a “decisive step” toward finalizing the exit deal with the EU within days. It sets in motion an elaborate diplomatic choreography of statements and meetings.

EU chief negotiator Michel Barnier declared there had been “decisive progress” — the key phrase signaling EU leaders can convene a summit to approve the deal, probably later his month.

Crucially, Barnier said that “we have now found a solution together with the U.K. to avoid a hard border on the island of Ireland.”

But the agreement, hammered out between U.K. and EU negotiators after 17 months of what Barnier called “very intensive” talks, infuriated pro-Brexit lawmakers in May’s Conservative Party, who said it would leave Britain a vassal state, bound to EU rules that it has no say in making.

Those “hard Brexit” voices include several ministers in May’s Cabinet. Emerging from the five-hour meeting at 10 Downing St., May said the Cabinet talks had been “long, detailed and impassioned.” She said there had been a “collective decision” to back the deal, though she did not say whether it was unanimous.

“I firmly believe, with my head and my heart, that this is a decision which is in the best interests of the United Kingdom,” she said.

In a warning to her opponents, May said the choice was between her deal, “or leave with no deal; or no Brexit at all.”

If the EU backs the deal, as it likely will, it must be approved by Britain’s Parliament. That could be a challenge, since pro-Brexit and pro-EU legislators alike are threatening to oppose it.

Pro-Brexit lawmakers say the agreement will leave Britain tethered to the EU after it departs and unable to forge an independent trade policy.

On the other side of the argument, pro-EU legislators say May’s deal is worse than the status quo and the British public should get a new vote on whether to leave or to stay.

In between those two camps are May’s supporters, who argue that the deal is the best on offer, and the alternatives are a chaotic “no-deal” Brexit that would cause huge disruption to people and businesses, or an election that could see the Conservative government replaced by the left-of-center Labour Party.

Failure to secure Cabinet backing would have left May’s leadership in doubt and the Brexit process in chaos, with exit day just over four months away, on March 29.

She still faces the threat of a coup attempt from her own party.

Under Conservative rules, a no-confidence vote in the leader is triggered if 15 percent of party lawmakers write letters requesting one. The required number currently stands at 48 lawmakers; only the lawmaker who collects the letters knows for sure how many have been submitted.

Pro-Brexit Conservative lawmaker Conor Burns said he wanted a change of policy rather than a new leader, but added: “There comes a point where if the PM is insistent that she will not change the policy, then the only way to change the policy is to change the personnel.”

The main obstacle to a withdrawal agreement has long been how to ensure there are no customs posts or other checks along the border between the U.K.’s Northern Ireland and EU member Ireland after Brexit. Britain and the EU agree that there must be no barriers that could disrupt businesses and residents on either side of the border and undermine Northern Ireland’s hard-won peace process.

The solution in the agreement involves a “single EU-U.K. customs territory,” to eliminate the need for border checks.

As part of the agreement, the U.K. will agree to follow EU rules in areas like animal welfare, environmental standards and workplace protections — another source of anger for Brexiteers, who say Britain should be free to set its own rules.

The solution is intended to be temporary — superseded by a permanent trade deal. But pro-Brexit politicians in Britain fear it may become permanent, hampering Britain’s ability to strike new trade deals around the world.

Leading Euroskeptic Conservative legislator Jacob Rees-Mogg urged his colleagues to vote against the deal, saying it “will lock us into an EU customs union and EU laws. This will prevent us pursuing a U.K. trade policy based around our priorities and economy.”

The draft agreement also mentions potential “Northern Ireland-specific regulatory alignment” to avoid a hard border.

Northern Ireland’s Democratic Unionist Party, which props up May’s minority government, insists it will oppose any deal that leaves Northern Ireland subject to different rules to the rest of the U.K. after Brexit.

“We could not as unionists support a deal that broke up the United Kingdom,” DUP leader Arlene Foster said.