LONDON (Reuters) - Britain struck a draft divorce deal with the European Union after more than a year of talks, thrusting Prime Minister Theresa May into a perilous battle over Brexit that could shape her country’s prosperity for generations to come.

While Brussels choreographs the first withdrawal of a sovereign state from the EU, May, a far from secure leader hemmed in by opponents in government and her own Conservative party, must now try to get the deal approved by her cabinet and, in the toughest test of all, by parliament.

Brexiteers in May’s party accused her of surrendering to the EU and said they would vote the deal down while the Northern Irish party which props up her minority government questioned whether she would be able to get parliamentary approval.

“These are momentous days and the decisions being taken will have long-lasting ramifications,” said Arlene Foster, leader of the Northern Irish Democratic Unionist Party (DUP) which keeps the government in power.

“The prime minister must win the support of the cabinet and the House of Commons. Every individual vote will count.”

The British cabinet will meet at 1400 GMT on Wednesday to consider the draft withdrawal agreement, a Downing Street spokesman said after Irish and British media were leaked details of the agreement on the text.

Sterling, which has seesawed since reaching $1.50 just before Britain’s 2016 referendum that saw a 52-48 percent margin for leaving the EU, surged on news of a deal but then erased some gains as opponents lined up to criticise May.

Brexit will pitch the world’s fifth largest economy into the unknown and many fear it will serve to divide the West as it grapples with both the unconventional presidency of Donald Trump and growing assertiveness from Russia and China.

Supporters of Brexit say that while the divorce might bring some short-term instability, in the longer term it will allow the United Kingdom to thrive and also enable deeper EU integration without such a powerful reluctant member.

SELLING BREXIT

A senior EU official confirmed that a draft text had been agreed. EU leaders could meet on Nov. 25 for a summit to seal the Brexit deal if May’s cabinet approves the text, diplomatic sources said.

The EU and Britain need an agreement to keep trade flowing between the world’s biggest trading bloc and the United Kingdom, home to the biggest international financial centre.

But May, an initial opponent of Brexit who won the top job in the turmoil that followed the referendum, has struggled to untangle nearly 46 years of EU membership without damaging commerce or upsetting the MPs who will ultimately decide the fate of the divorce accord.

By seeking to leave the EU while preserving the closest possible ties, May’s compromise plan has upset Brexiteers, pro-Europeans, Scottish nationalists, the Northern Irish party that props up her government, and some of her own ministers.

It is unclear when parliament might vote on a deal. To get the deal approved she needs the votes of about 320 MPs in the 650-seat parliament. She faces a deeply divided government, party, parliament and country.

BREXIT BETRAYAL?

Prominent Brexiteers such as Conservative lawmaker Jacob Rees-Mogg and former Foreign Secretary Boris Johnson said May had sold out the United Kingdom and that they would oppose it.

Slideshow ( 10 images )

“It is a failure of the government’s negotiating position, it is a failure to deliver on Brexit, and it is potentially dividing up the United Kingdom,” Conservative lawmaker Jacob Rees-Mogg said.

The opposition Labour Party, which has said it would oppose any agreement that does not retain “the exact same” economic benefits that it now has with the EU, said it was unlikely the announced deal was right for Britain.

“It is vassal state stuff,” Johnson said, adding that he would vote against such an unacceptable accord. “Chuck it out.”

Johnson’s brother, Jo, a pro-European, resigned from May’s government on Friday, calling for another referendum to avoid her Brexit plans unleashing Britain’s greatest crisis since World War Two.

Slideshow ( 10 images )

IRELAND

May formally began Britain’s divorce in March 2017, ushering in tortuous negotiations on everything from space exploration and fishing territories to selling complex financial products and the future of the land border on the island of Ireland.

As deadlines passed, officials such as Britain’s Olly Robbins and the Commission’s Sabine Weyand, a German, raced to get a deal in late night sessions at the European Commission’s modernist Berlaymont building in Brussels.

With less than five months until Britain leaves the EU, the so-called Northern Irish backstop was the main sticking point.

The backstop is an insurance policy to avoid a return to controls on the border between the British province of Northern Ireland and EU member state Ireland if a future trading relationship is not agreed in time.

The British government supplied no immediate details on the Brexit deal text, which runs to hundreds of pages.

Three EU sources said the backstop would come in the form of a UK-wide customs arrangement, with specific provisions for Northern Ireland which go deeper on the issue of customs and alignment with the rules of the EU single market than for the rest of the United Kingdom.

It would include a review mechanism to bridge between EU demands that the insurance policy is permanently available and Britain’s request to avoid being held in a customs alliance with the bloc perpetually.

The DUP has ruled out any deal that treats Northern Ireland differently.