The UK has voted to leave the EU - a process that has come to be known as Brexit. Here is what is likely to happen next.
The story so far
At exactly 06:00 BST on 24 June it was confirmed that the UK had voted to leave the European Union. The first thing to stress is that the UK will not leave immediately. The UK is still a member of the EU and will probably remain so for several years. But the vote has already triggered an extraordinary chain of events.
A new prime minister needed
In a statement outside Downing Street, David Cameron said the government would respect the result and carry out the instructions of the British people, reassuring the 2.9 million EU citizens in the UK that they will not be adversely affected.
Although it was his responsibility to remain in No 10 to "steady the ship", he announced he would step down in the autumn as he was not the right "captain to steer the country to its next destination".
A new Conservative leader and prime minister is expected to be elected by 9 September.
Under the party's existing rules, Conservative MPs would hold a series of ballots, with all but the two most popular candidates being eliminated. The final two will then go into a run-off in which all Conservative Party members will get a vote. This was the system used to elect Mr Cameron in 2005.
Will Labour follow suit?
Labour leader Jeremy Corbyn has come under huge pressure from within his party to consider his position but he has insisted he will not step down.
MPs have passed a motion of no confidence in Mr Corbyn, accusing him of weak leadership during the referendum campaign and he is trying to fill gaps in his shadow cabinet following a wave of resignations.
This is not a formal mechanism for removing Mr Corbyn and he could survive even if the vote, should it take place, went against him.
He has warned: "Those who want to change Labour's leadership will have to stand in a democratic election, in which I will be a candidate."
His critics had hoped the vote and resignations might force him to either step down voluntarily or precipitate a formal challenge - which would require 50 MPs to write to the party's general secretary and a challenger to come forward with sufficient nominations to get on the ballot paper.
Shadow chancellor John McDonnell has effectively challenged the would-be challengers, saying that even if Mr Corbyn was forced to stand for re-election, he would win when it came to a vote of the party members and supporters. This one looks set to run for a while yet.
The markets react
Market reaction to the referendum result was immediate and dramatic.
The FTSE 100 index of leading shares fell 8% after opening in London on Friday. There was a big sell-off of bank shares and housebuilders, with Barclays and RBS at one point down by more than 30%. By the end of trading, the index had bounced back, closing 2.8% down. The FTSE 250 index closed down 7% on Friday.
The value of the pound has also been hit hard on the foreign exchange markets, tumbling to lows not seen since 1985. At one stage, it hit $1.3305, a fall of more than 10%, although it too slightly recovered to close down 9% at $1.36.
Chancellor George Osborne made a statement before the UK stock market opened on Monday in a bid to calm the markets. He said the UK was ready to face the future "from a position of strength" and indicated there would be no immediate emergency Budget.
He said there would still need to be an "adjustment" in the UK economy, but added it was "perfectly sensible to wait for a new prime minister" before taking any such action.
Bank of England governor Mark Carney - who is likely to emerge as a key figure in the coming days - said some "market and economic volatility" could be expected in the wake of the Brexit vote but the Bank was well prepared. He said it stood ready to offer all necessary assistance to ensure financial stability, including £250bn of extra liquidity for the banking system and potential support for sterling.
Business leaders have appealed for calm but also more clarity over how the process of leaving the EU will proceed and who will lead it. A number of firms have said they will review their investment in the UK. Sources within Morgan Stanley have told the BBC that the bank is stepping up a process which could see up to 2,000 of its London-based investment banking staff being relocated to Dublin or Frankfurt.
European leaders respond
All EU leaders wanted the UK to stay in the bloc and a Leave vote has been met with disappointment and dismay across the Channel.
Hastily-convened meetings are taking place in Brussels and across foreign capitals on how to deal with the fallout of the UK's decision, with the leaders of Germany, France and Italy meeting on Monday ahead of a wider EU summit later this week.
European Council President Donald Tusk has appealed for unity among the EU's 27 other members, saying the vote is historic but "not a moment for hysterical reactions". German leader Angela Merkel said the vote was "regrettable" and a "watershed moment" for the EU.
What will happen next is difficult to predict. A long, hard road of negotiations between the UK and EU beckons although it is unclear when this process - likely to take years - will begin. The German government said Britain should be given a reasonable amount of time to negotiate its withdrawal.
EU leaders are particularly worried about the prospect of "contagion", with the UK's decision already fuelling demands from populist, anti-EU parties in France and the Netherlands for referendums of their own on EU membership.
Pushing the exit button
There is a formal legal process for withdrawing from the EU - enshrined in Article 50 of the 2009 Lisbon Treaty - although it has never been invoked before.
Mr Cameron has said it should be up to his successor to decide when to activate Article 50 by notifying the European Council. Once this happens, the UK is cut out of EU decision-making at the highest level and there will be no way back unless by unanimous consent from all other member states.
Quitting the EU is not an automatic process - it has to be negotiated with the remaining 27 members and ultimately approved by them by qualified majority. These negotiations are meant to be completed within two years although many believe it will take much longer. The European Parliament has a veto over any new agreement formalising the relationship between the UK and the EU.
Leave campaigners have said there is no need to trigger Article 50 immediately, suggesting that first there should be a period of informal discussions with other EU members and the European Commission to iron out the main issues and a feasible timetable.
Some have even suggested that Article 50 should not be invoked until after the French presidential elections in May 2017 and the German parliamentary elections next year to avoid Brexit becoming an issue in the campaigns.
The idea, they say, would be to allow other EU leaders the time to realise they need a "friendly" trade deal with the UK to continue exporting their consumer goods into the British market without tariffs.
Any such trade agreement - separate to the negotiations over the "terms of divorce" - would need to be approved separately by the UK and by every remaining EU member, with Leave supporters envisaging this could be completed by 2020.
Britain could, technically, ignore all of this and simply write the EU out of its laws, although that wouldn't make future negotiations any easier. The BBC's legal correspondent Clive Coleman says this would mean ripping up the UK's obligations under the Lisbon Treaty and therefore, while it was possible, remained very unlikely.
As only one part of one country has ever left the European Community - Greenland more than 30 years ago (read Carolyn Quinn's feature on how they left) - we are in uncharted territory here. While Article 50 negotiations are taking place, the UK is bound by all existing EU laws and treaty obligations. But after two years, this would no longer be the case and British membership could cease.
Remain campaigners warned this could see the UK revert to trading with the EU under World Trade Organization rules, which would involve exporters being hit by import taxes, or tariffs.
Parliament will not stay silent
The process of extricating the UK from the EU will ultimately involve rescinding the 1972 European Communities Act, the brief piece of legislation that brought the country into the European Economic Community, as it was then known, and which gives primacy to EU law in the UK.
It will also mean sifting through an estimated 80,000 pages of EU agreements, which have been enacted over the past five decades, to decide which will be repealed, amended or retained - a process which Parliament will want to oversee.
Parliament will ultimately have to ratify the treaty authorising UK withdrawal.
The majority of the UK's 650 MPs were in favour of Britain staying in the EU and while they will have to respect the will of the British people, they will not be silent bystanders. There have already been moves among the 450 or so MPs who want to stay in the EU, across the Labour, Conservative, SNP, Plaid Cymru and Green parties, to keep the UK in the single market in any exit negotiations.
This, dubbed "reverse Maastricht", would mean Britain would have to keep its borders open to EU workers and continue paying into EU coffers - which is likely to be unacceptable to most of the 17 million people who voted Leave in the referendum.
They say it would be legitimate for MPs to do this because the Leave campaign has refused to spell out what trading relationship it wants the UK to have with the EU in the future - and it would demonstrate the sovereignty of Parliament the Leavers were so keen to restore.
Who will lead Britain's negotiations?
Then there is the question of who will do the negotiating for Britain.
The most senior members of the government - David Cameron, Chancellor George Osborne, Foreign Secretary Philip Hammond and Home Secretary Theresa May - are all Remain supporters and some of them may choose to depart when the PM stands down.
During the campaign, the Leave side said that it would be happy for existing ministers and senior civil servants - including cabinet secretary Sir Jeremy Heywood - to lead the negotiations although they would expect senior Leave figures to play a very prominent role, as well as figures from other parties, business, law and civil society.
Now, however, it seems certain the next prime minister - whoever they may be - will take charge of the process. Could this be either Boris Johnson or Michael Gove - both of whom were tipped for major promotions whatever the outcome of the vote.
The devolved administrations in Scotland, Wales and Northern Ireland will also want to be represented in the process.
The UK's future up for grabs?
The Brexit vote will fuel concerns in Westminster that the future of the United Kingdom is now in serious doubt.
The SNP warned during the campaign that if - as has happened - the UK overall voted to leave the EU but Scots voted to remain, Scotland would be taken out of the EU "against its will" and this could be the trigger for another independence vote.
Senior SNP figures have said the vote shows Scotland sees its future in the EU and the issue of its own constitutional status could be revisited.
First Minister Nicola Sturgeon has said the issue is now back "on the table" while her predecessor Alex Salmond has gone further, saying a second vote could take place within the next two and a half years, depending on how long it takes the UK to depart.
The SNP's failure to win a majority in last month's Holyrood elections means a second vote will be harder to achieve, with the UK government less disposed than it was in 2012 to accept the idea. There are, of course, no guarantees that an independent Scotland would be admitted into the EU.
There are also concerns in Northern Ireland about the implications of the Brexit vote for its relationship with the Republic of Ireland. Remain campaigners warned that a Brexit vote could herald the return of "hard" border controls between the North and South. The Irish government has said the future of the border is one of a number of priority issues in its contingency planning.
Sinn Fein has called for a vote on the reunification of Ireland but this has been rejected by the UK government.