What has happened?
A referendum – a vote in which everyone (or nearly everyone) of voting age can take part – was held on Thursday 23 June, to decide whether the UK should leave or remain in the European Union.
Leave won by 52% to 48%.
The referendum turnout was 71.8%, with more than 30 million people voting. It was the highest turnout in a UK-wide vote since the 1992 general election.
What was the breakdown across the UK?
England voted strongly for Brexit, by 53.4% to 46.6%, as did Wales, with Leave getting 52.5% of the vote and Remain 47.5%.
Scotland and Northern Ireland both backed staying in the EU. Scotland backed Remain by 62% to 38%, while 55.8% in Northern Ireland voted Remain and 44.2% Leave.
What happens now?
For the UK to leave the EU it has to invoke an agreement called Article 50 of the Lisbon Treaty.
Cameron or his successor needs to decide when to invoke this – that will then set in motion the formal legal process of withdrawing from the EU, and give the UK two years to negotiate its withdrawal.
The article has only been in force since late 2009 and it hasn’t been tested yet, so no-one really knows how the Brexit process will work, according to BBC legal correspondent Clive Coleman.
Mr Cameron, who has said he would be stepping down as PM by October, said he will go to the European Council next week to “explain the decision the British people have taken”.
EU law still stands in the UK until it ceases being a member – and that process could take some time.
The UK will continue to abide by EU treaties and laws, but not take part in any decision-making, as it negotiates a withdrawal agreement and the terms of its relationship with the now 27 nation bloc.