Britain has been part of a club of countries called the European Union, or EU, since 1973.
In a referendum, held on 23 June 2016, the majority of adult Britons voted to leave the EU.
On 29 March 2017 the countdown to the UK formally leaving the EU, also known as Brexit, began.
Here's a timeline of the key events leading up to the EU referendum and what happened next.
The European Economic Community (EEC) is set up by six countries; Belgium, France, Germany, Italy, Luxembourg and the Netherlands. The EEC would later become the EU.
Britain finally joins the EEC, having been rejected twice previously by the then French President, Charles de Gaulle.
The new Labour government holds a referendum on whether to stay in the European communities, the result is to remain.
David Cameron promises a referendum if the Conservatives win the election.
The Conservatives win the election.
Following a referendum Britons vote 52 percent to 48 percent in favour of leaving the EU.
Conservative Prime Minister David Cameron, who led the campaign to keep Britain in the EU, announces his resignation.
Theresa May becomes Prime Minister after winning the Conservative leadership election.
Theresa May sets out her Brexit strategy, saying Britain will leave Europe's single market and control EU immigration.
Theresa May triggers Article 50 which starts the clock on the process of the UK leaving the EU. The Brexit deadline is set for March 29 2019.
Mrs May loses her majority in Parliament.
Northern Ireland's DUP - led by Arlene Foster - makes a deal with the Conservatives and its votes allow Mrs May to stay in power.
Formal negotiations on withdrawal begin between the UK and the EU.
Rebel Tory MPs side with the Opposition (the Labour Party) forcing the government to guarantee a vote by MPs on the final Brexit deal, when it has been struck with Brussels.
British and EU negotiators reach a draft agreement on withdrawal. EU leaders approve this on 25 November.
In the first parliament vote on the deal MPs vote 432 to 202 against it - the biggest government defeat in British parliamentary history.
The next day the government narrowly survives a vote of no confidence, which could have triggered a general election.
The House of Commons rejects the deal again 391 to 242. On March 27, May promises to resign if her Brexit deal is adopted.
Ministers reject the deal again by 344 to 286. This was the day Britain was supposed to leave the EU, but the process is delayed.
The delay means Britain is obliged to organise European Parliament elections on May 23, which are won by the anti-EU Brexit Party..
After the European election defeat May announces that she will step down as Conservative leader on 7 June.
Boris Johnson is voted in by Conservatives as their new leader, becoming prime minister the next day. He promises to take Britain out of the EU on October 31 - with or without a deal.
Queen Elizabeth II gives her approval to a law that would force the government to delay Brexit if it is not able to strike a withdrawal deal with Brussels.
Prime Minister Boris Johnson publishes his "final" Brexit proposals, which are rejected by the EU.
The prime minister and his Irish counterpart Leo Varadkar say they see a "pathway" to a deal after talks over the main sticking point - how to keep open the border, for trade and travel, between the British province of Northern Ireland and the Irish Republic, a member of the EU.
The European Union and Britain announce their agreement on a new draft Brexit agreement.
It is then supported at a key EU summit by the other 27 EU members, but also needs approval by the British and European parliaments.
The British parliament sits on a Saturday for the first time in 37 years, but MPs vote to delay a decision on the draft deal, arguing they need more time to study its contents before the October 31 deadline.
It means Johnson has to seek another Brexit delay from the EU which is accepted on 28 October.
Parliament approves a general election on 12 December.
The second Brexit deadline passes without a deal being done
The UK's EU Withdrawal bill becomes law, after a smooth passage through Parliament compared to the earlier difficulties.
The UK officially leaves the EU at 11:00pm UK time (midnight European time).
An 11-month transition phase begins, running to 31 December 2020.
Most of the pre-Brexit arrangements will remain the same while both sides work out what the future EU-UK relationship will look like.