London CNN  — 

British and European Union negotiators have agreed on a draft Brexit deal, UK Prime Minister Theresa May’s office said Tuesday, more than two years after the country voted in a divisive referendum to withdraw from the bloc.

May has called an emergency Cabinet meeting for Wednesday to discuss the draft deal, her office announced, after months of tortuous negotiations. Marathon talks this week had stretched late into the night.

A Downing Street spokesman said the Cabinet would meet at 2 p.m. Wednesday to “consider the draft agreement the negotiating teams have reached in Brussels, and to decide on next steps. Cabinet ministers have been invited to read documentation ahead of that meeting.”

Key ministers were seen entering the Prime Minister’s office to be briefed one by one on the text, believed to run over hundreds of pages.

It was a significant moment for May, whose rocky premiership hangs on reaching a Brexit deal. She had hoped to strike a draft agreement by this week to have any chance of getting the deal through the required ratification processes by the time Britain leaves the EU at the end of March.

She is now faced with the task of selling the deal to her divided Cabinet, amid talk that some of her senior ministers are so dissatisfied with the deal that they are considering resigning.

Even if the Cabinet grudgingly approves the draft, May must then get it through the UK Parliament, where she does not have a majority of MPs.

British Prime Minister Theresa May leaves Downing Street on October 15, 2018.

Boris Johnson, who resigned as foreign secretary earlier this year, made it clear he would not vote for the deal. “It is not the right way forward, there’s a better deal to be done,” he told Sky News. “There’s no point in leaving the EU if you end up being run by the EU.”

Nigel Dodds, deputy leader of the Democratic Unionist Party, a right-wing bloc from Northern Ireland that props up May’s government in Parliament, said the party would consider its position. “The trick will be for Theresa May, can she satisfy everyone? It is going to be a very, very hard sell, I would have thought, but let’s wait and see the actual detail,” he said, according to Reuters.

EU officials urged caution, saying there were still details to be agreed upon. One diplomat said the EU was in “a waiting mood.”

“The EU member states have not seen the draft. It’s at the technical level. We have an idea of the main parameters, a broad backstop that includes a custom union for the UK and regulatory alignment for Northern Ireland. But the member states have not seen the text at this stage,” the official told CNN on condition of anonymity.

Another EU diplomat said: “You can’t consider it a deal until it’s agreed by British Cabinet.”

Ambassadors from the EU’s other 27 states will meet in Brussels on Wednesday at the same time as the UK Cabinet.

Divorce details

The agreement sets out the terms of Britain’s divorce from the union after 45 years of membership. It was reached after talks went through the night and the two sides agreed to all the technical details of the withdrawal.

Talks had stalled over the thorny issue of the border between Ireland, which remains an EU member, and Northern Ireland, which is part of the United Kingdom.

Both sides wanted to avoid a “hard border” between the territories but reached an impasse over the terms.

Hardline Brexit supporters in May’s Conservative Party, like Johnson, have argued that the Prime Minster’s negotiating approach would leave the country too close to existing EU rules and regulations.

Chief among hardliners’ concerns is that an agreement on the EU-UK land border will tie the country to the EU’s customs union and parts of the single trade market.

“It is vassal state stuff,” Johnson said, according to Reuters. “Chuck it out.”

CNN’s Erin McLaughlin, James Frater and Lindsay Isaac contributed to this report.