The campaign to leave the European Union has won the referendum. It means the UK is now committed to withdrawing from the group of 28 countries, a process that has come to be known as Brexit. What does this mean for the UK and EU?
UK special deal binned
The deal that Prime Minister David Cameron negotiated with the EU in February, giving the UK a special status as an EU member, will now be scrapped.
The UK won a guarantee that it would not suffer discrimination by being outside the eurozone. That was to safeguard the City of London's authority, as Europe's biggest financial centre. In return, the UK pledged not to block deeper eurozone integration.
If the UK manages to negotiate continued access to the EU single market on preferential terms the deal is unlikely to include the non-discrimination safeguards.
Mr Cameron has now said he will stand down by October and pass on to his successor the role of invoking the EU's Article 50 procedure to negotiate the terms of the UK withdrawal.
Article 50 of the Lisbon Treaty, which has never been used before, sets a two-year time limit for reaching a deal. Generally seen as a tight deadline, it can be extended only if all 28 member states agree.
Once the UK tells the EU that it is withdrawing under Article 50, it "shall not participate in the discussions of the European Council or Council or in decisions concerning it", the rule says. So on some issues the UK will be cut out of EU decision-making at the highest level before it actually leaves.
The process requires the UK to unpick some 80,000 pages of laws binding the UK to the EU. Some will be kept, because some areas of EU policy are shared with non-EU countries, like Norway and Switzerland.
Under this "divorce settlement", as some have called it, the UK and EU must agree how to divide assets, resolve EU budget issues and set out the future rights of EU nationals in the UK and vice versa.
The settlement requires approval by a majority of EU members, plus the European Parliament and UK Parliament.
New trade relationship
Talks to determine new UK-EU trading arrangements could start during the two-year negotiating period for withdrawal, but not necessarily.
If the EU waits until the UK's formal withdrawal, the negotiations might drag on for another five years or more. Pending a deal, the UK will trade with the EU under World Trade Organization (WTO) rules.
That would mean UK exporters paying new EU import tariffs and facing non-tariff barriers, in the same way that China and the US trade with the EU. UK services - accounting for 80% of the UK economy - would lose their preferential access to the EU single market.
Free trade deals that the EU negotiated with 53 countries, including Canada, Singapore and South Korea, will no longer apply to the UK. If the UK wants the benefits of them it will have to renegotiate with those countries.
The Remain camp said full access to the EU single market - the world's biggest free trade area with 500 million consumers - was crucial for the UK. But free movement of workers, payments into the EU budget and acceptance of the EU rulebook are conditions for that access.
The EU is unlikely to bend on those conditions, because it does not want more members to leave the club. The UK might well sign up to those conditions, but it would not be able to influence EU rules, as it would lack a vote. Many in the Brexit camp see that position - exemplified by Norway - as unacceptable.
The UK's main selling point is that it is a big market for EU exports, such as French food and German cars.
No more budget contributions
The UK will stop paying into the EU budget once it formally leaves the bloc.
So the UK's current net contribution of about £8.5bn (€11bn; $12.5bn) annually will stay at home. It could be spent partly on the National Health Service, as some in the Brexit camp have suggested, or used to scrap VAT on fuel.
But UK farmers will no longer get direct payments from the EU, which were worth about £2.4bn in 2015. It is not clear how much of that, if any, the UK government will continue paying.
Nor is it clear how much the UK's poorest regions will get in future, now that they no longer qualify for EU regional funding.
The UK will try to reduce immigration from the EU, probably with a points-based system like Australia's. It means giving priority to high-skilled workers and blocking entry to low-skilled ones. Many jobseekers from the EU may be told to leave.
But first the UK will have to clarify the status of the nearly 2.2 million EU workers living in the UK. The rules for family reunions may get tougher. But any block on freedom of movement is unlikely for at least two years, while the UK is negotiating Brexit.
Nearly two million UK nationals also live abroad in EU countries - so any British measures targeting EU workers could trigger retaliation against UK nationals abroad.
What the UK can start doing immediately, however, is tighten the rules for migrant benefits.
Brexit will undoubtedly boost the fortunes of anti-EU, anti-immigration parties in some other EU countries. It may also inspire Eurosceptics in some other countries to hold their own referendums on EU membership. Brussels would see that as a "domino" effect - a nightmare scenario for the European project.