Britain has two years until its membership runs out, but this can be extended
Britain is to officially trigger the process for leaving the European Union on Wednesday March 29th.
This is done through Article 50 of the Lisbon Treaty.
This says that any member state may decide to withdraw from the union in accordance with its own constitutional requirements.
It says the EU "shall negotiate and conclude an agreement with that state, setting out the arrangements for its withdrawal, taking account of the framework for its future relationship with the union."
It says these negotiations will be concluded on behalf of the union by the European Council, after getting the consent of the European Parliament.
The UK and EU have two years from the date of the trigger, March 29th, to reach agreement.
Failing that, Britain could either leave without agreement - or the two year period can be extended.
However this can only be done if the the European Council, in agreement with Britain, unanimously decides to do so.
"The legal consequence of a withdrawal from the EU is the end of the application of the EU Treaties (and the Protocols thereto) in the state concerned from that point on," a European Parliament briefing document on the article says.
"EU law ceases to apply in the withdrawing state, although any national acts adopted in implementation or transposition of EU law would remain valid until the national authorities decide to amend or repeal them."
Any withdrawal agreement will need to address the phasing-out of EU financial programmes and other EU norms.
Experts agree that in order to replace EU law, Britain will need to enact substantial new legislation.
The withdrawal agreement could contain provisions on the transitional application of EU rules, which would otherwise disappear with the withdrawal.
After March 29th, the European Council will provide guidelines for negotiations between the EU and the UK, with the aim of concluding an agreement setting out concrete withdrawal arrangements.
European Council President Donald Tusk has said these will be presented to the 27 EU member states "within 48 hours of the UK triggering Article 50".
If an agreement is reached, the European Parliament and European Council then vote on it.
But there is no provision on whether British MEPs will be allowed to participate in either debates in the parliament, or from voting on the motion to consent to the withdrawal.
The council would need to pass the agreement with a 'super qualified majority', without the participation of the UK.
The qualified majority is defined in this case as at least 72% of the members of the council.
But unlike allowing new members into the EU, the withdrawal of a state does not require ratification by the remaining member states.
This is not the first time a nation has left the EU.
In a referendum on February 23rd 1982, Greenland decided, by 53% to 47%, to leave the then European Communities (EC).
However, the 1985 'exit' of Greenland from the EC is legally speaking not a 'withdrawal' as Greenland was not a member state of the EU but was, and remains, part of Denmark.
Due to its former status as a colony and its distance from the EU, Greenland became an 'associated overseas territory', with special arrangements with the EU, particularly with regard to fisheries.