It has been a long road since the referendum vote to leave the EU on June 23 2016.

A two-year period of negotiation was formally triggered by the UK's Article 50 letter on March 29 2017 and actual talks were delayed further by the snap general election of June 8.

A joint report was agreed by Theresa May and European Commission president Jean-Claude Juncker on December 8 but left some of the most contentious issues to be thrashed out.

On Wednesday, November 14 Theresa May spent five hours locked in crunch talks to secure the backing of her cabinet for draft plans of the final deal - but what are the next steps?

The Herald:

What's in the Withdrawal Agreement?

While the details of the agreement will remain unclear until the Cabinet meeting concludes, the Agreement covers every aspect of the UK's "divorce" deal from the EU.

Key issues covered by the agreement include the future rights of British expats living on the continent and Europeans in the UK, the settlement of the UK's financial liabilities (estimated at up to £39billion) and the status of the border of the island of Ireland.

While the agreement itself will spans more than 500 pages, a shorter political declaration sets out a framework for future relations between the UK and EU in areas like trade and security co-operation.

Why has the agreement taken so long to be drawn up?

The draft text of the deal was only completed yesterday and it faces a number of political obstacles before finalised terms of the UK's exit from the European Union are confirmed. 

The main obstacle to an agreement has been the question of the Irish backstop, which will be the UK's only land frontier with the remaining EU after Brexit.

Neither side wants a "hard" border with physical checkpoints and customs inspections, which they fear could undermine the Northern Irish peace process.

How are they proposing to keep the border open?

Both sides believe an eventual trade deal should resolve the issue but Brussels has insisted on a "backstop" arrangement as insurance to protect the border while a deal is negotiated.

EU proposals for a backstop keeping Northern Ireland inside the European customs area were rejected by Mrs May for effectively creating a border in the Irish Sea.

Her counter-proposal of a whole-UK temporary customs union was rebuffed by Brussels over the issue of Britain's unilateral right to pull out.

It is understood that the draft agreement introduces a review mechanism for ending the arrangement.

What opposition will the draft agreement face in Parliament?

Mrs May will face resistance from Tory Brexiters like Boris Johnson and Jacob Rees-Mogg who fear that a deal could tie the UK indefinitely to Brussels, following rules which it has no part in shaping.

The DUP, which props up her minority Government in the Commons, will challenge anything which treats Northern Ireland differently from the rest of the UK.

Remainers within the Conservative Party will argue that the draft offers worse terms than the UK already enjoys as a member of the EU.

Labour has said it will oppose any agreement which fails to support jobs and the economy and leader Jeremy Corbyn has already said the draft "is unlikely to be a good deal for the country".

EU-backing Liberal Democrats and the SNP are expected to vote against the deal.

What happens if the deal fails to win support in Westminster?

Theresa May has heavily pushed a "this deal or no deal" rhetoric, claiming that the alternative is for the UK to crash out of the EU without any agreements in place. 

If challenged, the Prime Minister is expected to use this to leverage MPs into backing her for the sake of stability.

However, there would also be huge pressure for a "People's Vote" second referendum to give the public the chance to decide whether it still wanted to go ahead with withdrawal.

And Labour would push for a general election to give someone else the opportunity to negotiate a better deal.

Is the Prime Minister's own position safe?

No. Theresa May could face a vote of no confidence if 48 Tory MPs demand one, with speculation that that number is close to being reached, or she could be ousted in the event of a snap general election.

Mrs May's knife-edge control of the House of Commons mean that she risks losing her effective majority and her ability to pass legislation if she alienates more than a handful of her backers.