What does the agreement say? Which bits are controversial? And will it now get through parliament?

Two and a half years after Britain voted to leave the EU, the UK cabinet on Wednesday night backed the text of the draft withdrawal agreement drawn up by British and European negotiators – but with a series of ministerial resignations already on Thursday, the fallout has already begun.

Brexit deal: Tory ministers meet to decide fate of agreement – Politics live Read more

Here is a non-exhaustive guide to what the agreement broadly says, which parts of it are proving controversial (and why), how likely the prime minister now is to get it through parliament, and what could happen next.

What is the withdrawal agreement?

Think of it as the separation agreement between the UK and the EU. Running to 585 pages, it covers three main areas:

Britain’s financial settlement with the EU to meet agreed commitments.

The post-Brexit rights of EU citizens in the UK and British citizens on the continent .

A mechanism to prevent a “hard border” on the island of Ireland.

The agreement also includes a much sketchier (and non-binding) seven-page political declaration outlining the two sides’ ambitions for their desired future trading relationship, on which negotiations have yet formally to start.

Play Video 2:28 Difficult days ahead, says Theresa May after cabinet backs Brexit deal – video

Why has it been so hard to reach?

While some of the detail took longer, the UK and EU agreed reasonably quickly on the so-called divorce bill and citizens’ rights.

The sticking point was the border between Northern Ireland and the Republic of Ireland, which after Brexit will also become the border between the UK and the EU. Because of the island’s troubled history, both sides want to avoid a hard border with customs checks that could become a source of friction.

The problem has been that, because the prime minister promised in January 2017 to take Britain out of both the EU’s single market (so as not to be an EU “rule-taker”) and the customs union (to allow it to strike its own trade deals around the world), customs and regulatory checks became almost inevitable.

Brexit phrasebook: single market The EU’s single market is more than a free-trade area. It aims to remove not just the fiscal barriers to trade (tariffs) but the physical and technical barriers (borders and divergent product standards) too by allowing as free movement as possible of goods, capital, services and people. In essence, it is about treating the EU as a single trading territory. See our full Brexit phrasebook.

What is the customs union? The European Union is a customs union. It allows free trade between countries inside it and allows imports in to the area by setting common tariffs. The area does not just include EU members. For instance, Turkey is part of the customs union for manufactured goods but not services or agriculture. The single market involves deeper integration of free movement of people, goods, services and money. This means laws need to be aligned. Some countries have access to the single market without being members of the EU’s customs union.

Ultimately, the Irish border is supposed to become a non-issue under the terms of the comprehensive free trade agreement (FTA) that the two sides are due to sign at some stage after Britain’s departure from the bloc on 29 March next year.

But because this may well not be negotiated by the end of the transition period in December 2020, the EU insisted on a “backstop” arrangement to avoid a hard border until a FTA came into effect. The row over the form this backstop should take is what prevented the withdrawal agreement from being sealed for so long.

'Judgment day': what the papers say about Theresa May's Brexit deal Read more

So how has this been resolved?

For months, Britain rejected the EU’s proposed backstop – in effect, keeping Northern Ireland in the customs union and single market – because it would require customs checks for goods crossing the Irish Sea and other arrangements meaning Northern Ireland was treated differently to the rest of the UK.

But the EU also rejected Britain’s suggestion that the whole of the UK should stay in a de facto customs union with the EU, mainly because the government wanted to be able to withdraw from such an arrangement unilaterally and at a time of its choosing (which, for the EU, meant it could not be considered a proper backstop).

Brexit phrasebook: a guide to the talks' key terms Read more

The solution involved concessions on both sides. For the EU, the chief negotiator, Michel Barnier, accepted the idea of a whole-UK customs union with the EU, satisfying the UK’s demands that its territorial integrity must be preserved.

But in return, Britain must accept that it will not be allowed to exit the backstop “unless and until” the EU agrees there is no prospect of a return to a hard border. It must also accept special “deeper” customs arrangements, closer to the single market, for Northern Ireland, and the EU’s so-called “level playing field” conditions for the whole of the UK.

These address member states’ concerns that de facto customs union membership without the obligations of the single market could give the UK an unfair advantage, so will require Britain to abide by EU rules on, for example, state aid, competition, the environment, tax and labour conditions.

So everyone’s happy?

Hardly. Conservative Brexiters, as is plain from Brexit secretary, Dominic Raab’s resignation letter, are appalled at the prospect of Britain potentially being “trapped” forever in a customs union with the EU – and at being forced to continue accepting EU regulations to boot.

The Northern Ireland unionists of the DUP – on whose votes in Westminster the government’s majority depends – appear to think those “deeper” customs arrangements, involving additional checks on livestock and food crossing the Irish Sea, breach their red lines on identical treatment for Northern Ireland.

For its part, Labour has said the agreement looks unlikely to support jobs and the economy or guarantee standards and protections, and it is therefore preparing to vote against it. More Tory remainers – heartened by Jo Johnson’s resignation last week – may also be encouraged to rebel.

What’s next?

The EU has confirmed an emergency EU summit can be called for 25 November to seal the deal, although events in the UK may intervene. Complicating the question, some EU member states feel the deal makes too many concessions to the UK.

In principle, the deal then has to pass through parliament early in December.

Many think it could fall at this hurdle, resulting either in a challenge to May’s leadership, a general election or even a second referendum (with staying in the EU still theoretically an option, although that would mean extending article 50, which set the deadline for the UK to leave as 29 March 2019).

But even if May and her deal survive, which appears increasingly unlikely, the agreement stipulates that the government must decide before June 2020 whether it wants to extend the transition period, fall into the Northern Ireland backstop arrangement or enter a permanent customs union – all options that would be anathema to Brexiters.

After that, of course, it has to seal the future trade deal, on which the two sides remain far apart.

Britain’s Brexit battle is a long way – a very long way – from over.