Theresa May has agreed to a draft Brexit withdrawal agreement with Brussels. Her cabinet backed it on Wednesday - but there have since been resignations.
Two cabinet ministers, and two junior ministers, have resigned over the deal - while some Conservative MPs have attempted to force a leadership contest by writing letters of no confidence in the prime minister. What happens now?
The basics: A reminder
The UK is due to leave the European Union at 23:00 GMT on Friday 29 March, 2019, after people voted by 51.9 percent to 48.1 percent for Leave in the 2016 referendum.
The UK and the EU have spent more than a year trying to agree on how the divorce - as it's often called - will work in practice.
Mrs May announced that a deal had been reached, and approved by cabinet, on Wednesday evening. But two cabinet ministers have since resigned.
The deal would also need to get the stamp of approval from MPs and, finally, the 27 other EU member states.
What has been agreed between the UK and EU?
A draft agreement on Britain's withdrawal from the European Union - including how much money will be paid to the EU, a 21-month transition period after Brexit day next March and commitments on the rights of EU citizens in the UK and UK citizens living in the EU.
It is not a trade deal - that will be hammered out during the transition period, if all goes as planned. They have also agreed to the text of a separate, shorter statement on the UK's future relationship with the EU, including the kind of trade deal the two sides want.
So what about a trade deal?
Alongside the 585-page withdrawal agreement is a five-page "political declaration" setting out what future UK and EU relations will look like.
This is a broad outline and is not binding - the details of a trade deal will be worked out during the transition period with both the EU and UK hoping to have an agreement in place by December 2020.
The political declaration envisages "a free trade area and deep co-operation on goods, with zero tariffs and quotas".
There would be "ambitious customs arrangements" that "build on" the arrangements in the withdrawal agreement.
The two sides say they want this new arrangement to solve the Irish border problem, removing the need for that troublesome backstop.
Have they solved the Irish border issue?
This was the major sticking point in talks with Brussels. Both sides are committed to avoiding a return to a visible Northern Ireland border with guard posts and checks. They believe that bringing them back would put the peace process at risk.
So they agreed to put in place a "backstop" - a kind of safety net to ensure there is no hard border whatever the outcome of future trade talks between the UK and the EU.
The backstop will mean that Northern Ireland would stay aligned to some EU rules on things like food products and goods standards.
That will prevent the needs for checks on goods at the Irish border, but would require some products being brought to Northern Ireland from the rest of the UK to be subject to new checks and controls.
The backstop would also involve a temporary single custom territory, effectively keeping the whole of the UK in the EU customs union.
But this bit is controversial - Brexiteers do not like the prospect of being tied to EU customs rules, and Northern Ireland's Democratic Unionist Party has said it will not tolerate anything that creates a new border down the Irish Sea.
The role of the European Court of Justice - which will still have jurisdiction in the UK on customs and single market rules - could also spark protests.
Mrs May says she does not want to have to use the backstop at all - and the withdrawal agreement says the UK and the EU will resolve to ensure it is not necessary by coming up with alternative arrangements.
They could also extend the transition if there is no long-term solution in place by July 2020 - but only once.
What else is in the agreement?
- Commitments over citizens' rights after Brexit - people will be able to work and study where they currently live, and to be joined by family members
- A proposed 21-month transition period after the UK's departure
- A "fair financial settlement" from the UK - also known as the £39bn "divorce bill"
- Protection for 3,000 "geographical indications" including Parma ham, feta cheese, champagne and Welsh lamb
- More on how what the draft agreement reveals
Who has resigned?
Dominic Raab resigned as Brexit secretary on Thursday morning, telling BBC News he quit the cabinet over "fatal flaws" in the draft agreement. He added the UK should be ready to risk a no-deal Brexit in the face of EU "blackmail".
Work and Pensions Secretary Esther McVey and junior Brexit minister Suella Braverman have also quit, as have Anne-Marie Trevelyan, a ministerial aide at the education department, and Ranil Jayawardena, a ministerial aide at the justice department.
Northern Ireland minister Shailesh Vara was the first to resign over Mrs May's agreement on Thursday morning, saying, it "leaves the UK in a halfway house with no time limit on when we will finally be a sovereign nation".
On Thursday afternoon, Rehman Chishti, the MP for Gillingham and Rainham, announced his resignation as vice-chairman of the Conservative Party and also as the prime minister's trade envoy to Pakistan.
So what happens next?
An emergency EU summit will be held on 25 November, where EU leaders are expected to sign off on the withdrawal agreement and future relationship declaration.
After that, Mrs May faces the fight of her life to get MPs to vote for it - something the BBC's political editor Laura Kuenssberg said could take place around 7 December.
Mrs May does not have a Commons majority and many MPs on her own side - as well as Labour and the other opposition parties - are sceptical about her Brexit plans, or openly hostile to them. The DUP, which Mrs May relies on in key votes, has already said it is likely to vote against it, claiming it will lead to the break-up of the United Kingdom.
A number of Conservative MPs have also said they will vote against it.
If Mrs May loses the vote, we enter uncharted territory. She may seek to renegotiate with the EU but most expect her time in No 10 to end. There could be a general election and/or a new prime minister.
Some Tory and Labour MPs hope she will head that off by postponing Brexit day and calling another referendum, something she has consistently ruled out.