text: European leaders have expressed shock, but most have said the result should not lead to a panic.
  Here, Europeans who contacted the BBC have been sharing their reaction to the result and their views on the UK's relationship with the EU.
  Angelique de Leur, The Hague, Netherlands
  "Congratulations to the UK for voting out of the European Union! The people showed great courage and voted against staying in the European nightmare any longer.
  "Seeing this makes me wonder why in my country people never really stand up for their frustration in the EU. In the Netherlands, hardly anyone ever shows up when there is a chance to vote for anything regarding the EU.
  "Furthermore do most people state that only "short-minded" people vote against the EU out of anger?
  "It was a very close call. But the majority of the people chose freedom from European enslavement. Congratulations!!"
  Rafael Sala, Barcelona, Spain
  "The main cause of the European-wide unrest is the narrow and miserable vision that our European leaders have on the European Union.
  "They have not initiated the path established by the treaty of 2012 on the economic union, they don't mention it, and the ideals of one budget, Eurobonds, euro protection for the bank accounts, are far away.
  "Few people raise their voices to speak about these failures.
  "My country, Spain, has to leave the EU sooner or later if the unity of Europe is not increased.
  "We suffer because a currency that fits us like an Armani suit fits a homeless person; it's an austerity policy that has impoverished more than 65% of our people. The results of the entry in the EU do not deserve the suffering."
  Stephanie Ayres, Kinsale, Ireland
  "For goodness sake, when a referendum outcome is 48.1% remain, 51.9% leave, then I'd say that you have an undecided nation.
  "The referendum is not legally binding. The UK government does not have to act on the outcome of this referendum.
  "I would say that the democratic way to look at the results is that there needs to be more debate, more real information, more time spent and more opinions taken.
  "Just because of that tiny margin, I don't think you can call the UK decided on the matter."
  Timo Pantsari, Espoo, Finland
  "Well now, this was a huge surprise to me as well as most of Europe when everyone woke up this morning.
  "Terrible news in both the short and long term for the UK. This will undoubtedly make Scotland have another referendum as they did in 2014.
  "Let me be the first one to warmly welcome Scotland as the next full member of the European Union and wish good luck to everyone in the newly 'independent United Kingdom'."
  Anna Filipek, MilanÃ³wek, Poland
  "Seriously Britain? It's sad that a majority of your people didn't realise that it's not a choice deciding about your no longer imperial country, but about commitment, devotion and enthusiasm of the whole Europe. If you voted Leave, you are selfish and you deserve to watch Scotland saying 'bye'.
  "I pity well-educated people of Britain, especially youngsters, that will need to face what the 'majority' brought them.
  "Of course nobody is happy about the current shape of EU. Of course EU requires lots of improvements.
  "But it's like marriage, it won't work without devotion and your divorce will give you depression, a bad example to other couples and will encourage your own kids to leave you.
  "As a person who truly believes in unity of European culture and heritage and supports sticking together against the odds, I feel really disappointed, even personally touched."
  Georg Schlomka, Flensburg, Germany
  "As a German I am truly thrilled by the UK's decision. Politicians all across Europe have, up to now, failed to grasp that while the concept of Europe is widely supported by the people, the EU in its present form is not.
  "So maybe this is a wake-up call for the rest of the EU and its respective member states - I certainly hope so. The alternative could only be an EU which grows even more repressive and less democratic than it is today.
  "I daresay that the UK would not have left the old EEC - so maybe it's time to go back to the roots."
  Otto Vennik, Dutchman in London
  "Well done Britain! Hopefully this will be the beginning of the end for the EU. Now if you will excuse me, I was looking for a NEXIT."
  Compiled by David Campanale
target: The UK has decided in a referendum vote to leave the European Union, but what do people from other EU countries think about Britain's big decision?