A revised Brexit deal has been agreed by the UK and EU. What is in it?
Most of the changes - to the deal agreed by Theresa May with EU in November 2018 - are to do with the status of the Irish border after Brexit. This issue has dominated talks for months.
All sides want to avoid the return of a "hard border" between Northern Ireland and the Republic of Ireland after Brexit - with checks and infrastructure that could be targeted by paramilitary groups.
Coming up with solutions to this - acceptable to all sides - has been very challenging.
The new protocol replaces the controversial Irish backstop plan in Theresa May's deal. Much of the rest of that deal will remain.
Here are some of the key new parts:
The whole of the UK will leave the EU customs union. The customs union is an agreement between EU countries not to charge taxes called tariffs on things coming from other EU countries, and to charge the same tariffs as each other on things coming from outside the EU.
Leaving the customs union means the UK will be able to strike trade deals with other countries in the future.
Legally there will be a customs border between Northern Ireland (which stays in the UK) and the Republic of Ireland (which stays in the EU), but in practice things won't be checked on that border.
The actual checks will be on what is effectively a customs border between Great Britain and the island of Ireland, with goods being checked at "points of entry" into Northern Ireland.
Taxes will only have to be paid on goods being moved from Great Britain to Northern Ireland if those products are considered "at risk" of then being transported into the Republic of Ireland.
A joint committee made up of UK and EU representatives will decide at a later date what goods are considered "at risk".
If taxes are paid on "at risk" goods that do not end up being sent on from Northern Ireland into the EU, the UK would be responsible for whether to refund the money.
Individual travellers won't have their baggage checked and taxes will not have to be paid by individuals sending goods to other people.
Separately, there will be limits agreed by the joint committee on the amount of help the government can give to Northern Irish farmers. The figure will be based on the amount they currently receive from the EU's Common Agricultural Policy.
Regulations on goods
When it comes to the regulation of goods (that's the rules they have to follow on things like labelling and manufacturing processes) Northern Ireland would keep to EU rules rather than UK rules.
That removes the need for checks on goods including food and agricultural produce at the border between Ireland and Northern Ireland, because both will be part of an "all-island regulatory zone".
But it adds to the checks between the rest of the UK - which will not necessarily be sticking to EU single market rules - and Northern Ireland.
Enforcing the rules
This will be done by UK officials at "points of entry" into Northern Ireland, but the EU will have the right to have its own officials present.
It seems those EU officials may be able to overrule UK officials. The agreement states that EU representatives will be able to ask UK authorities to take certain steps in individual cases and they will have to do so.
Northern Ireland's say
Because Northern Ireland will be set apart from the rest of the UK when it comes to customs and other EU rules, the deal gives its Assembly a vote on these new arrangements.
But this vote would not happen until four years after the end of the transition period (the time after Brexit when everything stays the same to allow everyone to prepare for the changes while the UK's future relationship with the EU is discussed). The transition period is due to run until at least the end of 2020. So the four-year period would run until the end of 2024.
If the Northern Ireland Assembly votes against the new arrangements, they would stop applying two years later, during which time the "joint committee" would make recommendations to the UK and EU on what to do about this.
If there were to be no agreement during this two year period, some form of hard border could re-emerge in Ireland, but it's unlikely that would be allowed to happen.
If the Assembly accepts the continuing provisions by a simple majority, they will then apply for another four years. If the deal has "cross-community support" then they will apply for eight years.
The deal defines cross-community support as more than 50% of unionist and nationalist Assembly members voting in favour, or at least 40% of members from each designation if in total at least 60% of members have voted in favour.
The UK government has said that if the Northern Ireland Assembly is still not sitting at that point, it will make alternative arrangements to make sure a vote can take place.
The new agreement says that EU law on value added tax (VAT - a tax added when you make purchases) will apply in Northern Ireland, but only on goods, not services.
But it also allows Northern Ireland to have different VAT rates to the rest of the UK, which would not normally be allowed under EU law.
For example, if the UK decided to reduce the VAT on household fuel to zero, Northern Ireland would still have to keep it at 5%, which is the EU minimum.
It also means that Northern Ireland may get the same VAT rates on certain goods as the Republic of Ireland, to stop there being an unfair advantage on either side of the border.
Some things have not changed:
Much of Mrs May's original Brexit deal will remain as part of the overall agreement. Some of the key areas are:
The transition - a period of time during which all of the current rules stay the same allowing the UK and the EU to negotiate their future relationship - is due to last until the end of December 2020.
The UK will need to abide by EU rules and pay into the EU budget, but will lose membership of its institutions.
The transition can be extended, but only for a period of one or two years.
Both the UK and EU must agree to any extension.
UK citizens in the EU, and EU citizens in the UK, will retain their residency and social security rights after Brexit.
Freedom of movement rules will continue to apply during transition. This means that UK nationals will be able to live and work in EU countries (and EU nationals will be able to live and work in UK) during this period.
Anyone who remains in the same EU country for five years will be allowed to apply for permanent residence.
(UPDATE: 13 December 2019 - This piece has been updated and reflects the delay of the Brexit date to the end of January 2020.)
The UK will have to settle its financial obligations to the EU.
There is no precise figure but the biggest part of this "divorce bill" will be the UK contributions to the EU budget until the end of the transition period at the end of 2020.
When Brexit was delayed it meant that some of that money was paid as the UK's normal membership contributions, so less of it was part of the divorce bill.
When the Brexit date was 31 October 2019, the Office for Budget Responsibility (OBR) estimated that the bill was about £32.8bn (down from £39bn).
To reach an estimate of what the bill would be for departure on 31 January 2020, you could subtract the £1.62bn that the OBR said was left to pay in membership fees in 2019 and 14% of the £10.69bn for the whole of 2020 (it's more than one twelfth because the EU usually requests a higher proportion of the contributions earlier in the year). That gives a total of just under £30bn.
The OBR expects that most of the money - about three-quarters of the total - would be paid by 2022, with some relatively small payments still being made in the 2060s.
Future UK/EU relationship
This is addressed in the political declaration. This text, which is not legally binding, has also been revised by UK/EU negotiators.
It says that both sides will work towards a Free Trade Agreement (FTA) and a high-level meeting will happen in June 2020 to see how that work is going.
The text also contains a new paragraph on the so-called "level playing field" - the degree to which the UK will agree to stick closely to EU regulations in the future.
The references to a "level playing field" were removed from the legally-binding withdrawal agreement and put in the political declaration, which is not binding.
It says that both sides will keep the same high standards on state aid, competition, social and employment standards, the environment, climate change, and "relevant tax matters".