LONDON — Brussels is happy. Westminster is in chaos.

After 18 months of fractious negotiations, the U.K. prime minister squeaked her Brexit deal through her divided top team Wednesday and now faces yet another struggle to survive, let alone steer the deal through an angry parliament that must sign off the divorce treaty in the coming weeks.

Theresa May's fate now rests on her ability to win support for the deal from the public and parliament — both of which remain deeply cynical about the agreement. With the Brexiteer wing of her party increasingly hostile, May is relying on the support of moderate backbench Conservative MPs — and the Labour Party — to get her deal through parliament, and neither on Wednesday appeared willing to come to her aid.

In Brussels, chief EU negotiator Michel Barnier hailed "decisive progress," a signal to European Council President Donald Tusk to call a special summit of EU leaders later this month in order to formally approve the agreement.

Underneath the obfuscating political fog sits a 585-page draft international treaty that protects the EU’s economic interests and inches it closer to its long-term political objectives, while leaving the U.K. as boxed in as ever by its own red lines. The central choices of Brexit remain, delayed but starkly unavoidable as the U.K. looks to begin negotiations to settle its future relationship with the European Union.

Negotiations weren't all one-way traffic. To reach a Brexit deal that stands even a chance of being agreed by British MPs, the EU bent its negotiating guidelines, offered significant concessions and blurred the legal limits of what the bloc's leaders said is possible.

Senior government officials on Wednesday night trumpeted a series of mini diplomatic victories in key areas of the Withdrawal Agreement — from the limited role of the European Court of Justice to the removal of the EU's proposed solution for the Irish border, which had originally envisaged Northern Ireland being “annexed” into the EU’s customs territory.

The document setting out the bare bones of what the U.K.'s future relationship with the EU will look like — published alongside the Withdrawal Agreement Wednesday — also holds out the prospect of the closest of close trade deals, going beyond any other EU agreement, but without the U.K. accepting free movement.

Even senior officials in Westminster and in Brussels expressed little doubt which side has emerged strongest.

Irish conundrum

Downing Street's officials say the key to winning public support for the Brexit deal is to show that it takes back control of “the two Ms” — money and (free) movement. After the 21-month transition period, May’s deal does this, they were keen to stress.

For the U.K., the toughest decision of all — whether to jettison Northern Ireland into the EU’s regulatory orbit or for the U.K. as a whole to become a permanent, rule-taking member of an EU customs union — has been kicked into the transition period. That transition itself can now be extended beyond the originally envisaged 21 months, for a period as yet undecided.

For the EU, its four freedoms are intact, tariff-free trade with the U.K. is protected, the City of London is not granted special treatment — and the long-term goal of a customs union with the U.K. that is under its control is still very much on the table.

Until the Irish border is resolved, the U.K. has agreed to remain in a temporary customs union with the EU. This will remain until a new customs “arrangement” can be agreed, which will be based on the temporary setup in the divorce deal. Brussels' line is blood red, the U.K.'s barely pink.

On top of this, until such a permanent customs arrangement is found, Northern Ireland risks being siphoned off into a separate regulatory environment to the rest of the U.K., taking rules made in Brussels on VAT, agriculture, environment and state aid without any say in shaping those rules — under the EU's proposed "backstop" solution. The U.K. will only be able to leave this arrangement with the EU's consent.

The Democratic Unionist Party — whose MPs prop up May's government in Westminster — has dismissed the agreement as a capitulation.

Speaking in Westminster Wednesday, the party's leader Arlene Foster said: “There were solutions out there, but unfortunately that was not the attitude which came from the Irish government or the European Union either. If she [Theresa May] decides to go against herself, then there will be consequences, of course there will be consequences.”

In her statement outside No. 10, May admitted the Northern Ireland compromises were the most difficult. “The choices before us were difficult, particularly in relation to the Northern Ireland backstop,” she said. “But the collective decision of Cabinet was that the government should agree the draft Withdrawal Agreement and the outline political declaration — this is a decisive step which enables us to move on and finalize the deal in the days ahead. These decisions were not taken lightly but I believe it is a decision that is firmly in the national interest."

'Snowball's chance in hell'

Without the DUP’s votes, May does not have a majority in parliament. But it is not just the DUP that is angry.

Taken together, the compromises, contradictions and sleights of hand in the document amount to a particularly bitter pill for many across British politics to swallow — and even if it is digested, MPs and officials fear it may poison the system for years to come as the battle moves on to what the future relationship will look like.

One Conservative MP, former chairman of the foreign affairs committee Crispin Blunt, said the agreement stands “a snowball’s chance in hell of passing the House of Commons.”

May’s former chief of staff Nick Timothy also attacked his former boss. In a column in the Telegraph he wrote: “The proposal presented to Cabinet is a capitulation. Worse, it is a capitulation not only to Brussels, but to the fears of the British negotiators themselves, who have shown by their actions that they never believed Brexit can be a success. This includes, I say with the heaviest of hearts, the prime minister.”

Asked whether Theresa May would be prime minister when Britain left the EU in March, Scottish First Minister Nicola Sturgeon said: “I wouldn’t put money on that.”

During Wednesday’s volatile five-hour Cabinet meeting, nine ministers spoke out against the deal, according to two special advisers with knowledge of the discussion. In her statement following the meeting, May could only say the deal had been reached “collectively" — code for “not unanimously.”

May does not need unanimity in parliament but she will struggle even for a majority.

One government minister close to May, asked how the numbers looked, replied simply: “Bumpy.” The prime minister will hope it's that good.

Ryan Heath contributed reporting.