If the UK does vote for a Brexit in the referendum, the country does not leave the EU overnight.
All it means in the short-term is that at some point Britain will begin the process of withdrawing as set out in EU treaties.
Article 50 of the Lisbon Treaty says that a member state which decides to leave must notify the European Council of its intention.
This task would fall to David Cameron or his successor in the event of his resignation or a leadership challenge.
Once that process starts, there’s a two-year window in which to negotiate an agreement to withdraw.
It can be extended, but only with the agreement of the 27 other member states.
During that time, the UK remains part of the EU and its laws would still apply.
If an agreement is not reached within the allocated period and no extension is agreed, then the UK would leave the EU at that point.
In those circumstances, it would have to rely on World Trade Organisation (WTO) rules and fall back on domestic immigration law.
The former would not necessarily be straightforward as it would require negotiations between the UK and other WTO members.
Many expect the process of negotiating the UK’s trading arrangements with the EU would mean more than two years are needed.
While it is possible an extension could be blocked, this would be unlikely as it would be in the remaining member states’ interests to secure a good deal.
Given immigration has played such a big role in the referendum campaign, it is doubtful a model like that of Norway or Switzerland would satisfy those who campaigned and voted for a Brexit.
The former is not a member of the EU, but is in the European Economic Area (EEA) and as such must apply the same free movement of people rules without having a say over them.
Switzerland is not a member of the EU either, but there is a bilateral free movement of persons agreement, which removed restrictions on EU citizens wishing to live or work there.