Brexit: Reaction from around the UK
Very different visions of where the UK's future should lie have been put under the spotlight by the vote to leave the EU.
BBC correspondents from around the UK reflect on how people have been voting and the implications at a local level.
Northern England - 'we've had enough'
The north of England has roared back at London - this result underlines the disconnect between the capital and the outlying parts of England, writes Danny Savage.
It showed in the results - London overwhelmingly In, huge parts of the north Out. For many this wasn't just about Europe, it was about a metropolitan elite telling them what to do. And then rebelling against it.
Throughout the campaign nearly everyone I talked to across this vast area was Out. A sunny day at Cartmel races in May saw people sporting 'vote leave' badges.
"This is a north versus south vote", one race-goer told me.
A day in Goole saw elderly women confiding that they didn't recognise their town any more and couldn't understand the language people in it spoke.
One prominent poll got it wrong last night - calling a Remain victory. That was soon shaken by a Remain win in Newcastle but one which was not as large as predicted. The rest is history.
What may be the case is that some people voted against the establishment rather than the EU. As was said during the campaign, the Remain argument was accused of being "too much Hampstead, not enough Hull".
Scotland - second referendum?
In Scotland the biggest and most pressing question is whether this vote could spell the break-up of the UK and hasten the day we see an independent Scotland, writes Scotland editor Sarah Smith.
Every region in Scotland voted to remain but the UK-wide result means that Scotland will nonetheless be leaving the EU.
This is exactly the scenario SNP leader Nicola Sturgeon envisaged when she said that if Scotland is "dragged out of the EU against its will", that could trigger a second referendum on Scottish independence.
Already, her predecessor as SNP leader Alex Salmond is saying that Ms Sturgeon will now call for a second referendum - indyref 2, as it is known in Scotland.
Ms Sturgeon said a second referendum was "highly likely" on Friday.
Birmingham - 'got our democracy back'
It was the biggest single voting district in the UK - around 700,000 registered voters - and one of the closest results of the night, writes Nick Higham.
Birmingham voted Leave by just 3,800 votes. In its West Midlands hinterland the vote was much clearer.
In manufacturing districts like Coventry they ignored the dire warnings from big business that a leave vote would hit the economy.
And some of the poorest areas voted by the largest margin to quit: 68% to 32% in Dudley.
In Birmingham itself the mood of commuters on their way to work ranged from exultation to disbelief.
"We're strong enough and brave enough and confident enough to get out there and show the world what we're really made of," said Lisa, who works in banking.
"We've got our democracy back and we can build an absolutely brilliant future for ourselves," said a smartly-dressed man who did not want to give his name. "It's going to be democracy not bureaucracy."
But Sam, who works in recruitment, said the decision would have a big impact in his job, and called it a big mistake: "We're going to go into a big recession."
"It's absolutely ridiculous," said a civil servant. "I cannot believe we've gone out. I'm an entrenched European, my girlfriend's German, my car is German, it's ridiculous."
The vote divided families. One woman told me she'd "followed her heart" and voted to leave, but her partner had voted to remain because they had a property in Europe.
And some had opted out altogether. Madeleine, a policy officer, said: "I didn't want to be accountable for my actions if I made the wrong decision."
So what did she think of the outcome? "A good result for maybe ten years time, maybe not so good for now."
South West England - farmers' perspective
As the crystal dawn breaks over the green patchwork landscape of the South West, farmers are already starting their working day when the referendum result is declared, writes Claire Marshall.
On one farm in rural Wiltshire the view from the milking shed is one of surprise - but satisfaction: the future is to be trading "with the world" not "a little club."
There is frustration with labyrinthine regulations and subsidies that support inefficient farms, calcifying the industry "in the hands of the older generation."
So, content, they get on with their job of providing the milk we put in our cups of tea and over which we mull the new landscape.
Hartlepool - "hard done by"
Fiona Trott writes: In a town where seven out of 10 people backed Brexit, one man I spoke to in Hartlepool summed up the general mood: "It's been a vote against the establishment".
Unemployment here is 9.4%. People feel hard done by. When you stop and talk to voters in the street, they tell you things couldn't get any worse, so why not vote for change?
It's probably why UKIP gained three seats here in the May elections. People here feel like they want to take back control.
What about the financial markets? One shopper told me:"It's just a blip".
Burnley - 'voices listened to'
"Time for a party", "it's a good day" and "we've got our country back" - just some of the voices in Burnley, writes Ed Thomas.
Voters in this east Lancashire market town sent a loud and clear message - they overwhelmingly voted to leave the EU by a majority of two to one.
Outside the local butchers we find Eric and his wife Lucy, both in their 70s and both in a celebratory mood.
Eric shouts "we are free of the idiots over there." He also says this means the "French will stop sending them (migrants) over the Channel."
Lucy, when asked, says she hates the EU and is glad to "have the power back." It is, she says, a "happy day."
For those voting "Out" there is a sense of achievement, that for the first time in a long time their voices have been listened to.
Burnley has been shaped by immigration and is home to some of the most deprived areas in the UK.
In a local hair salon, just yards from a Romanian busker, we speak to Michael and Stacey. They say "power is back with us" and suggest that the voices of doom "are scaremongering."
But not everyone is celebrating - here we also find 16-year-old Molly with her mother, Liz.
Both are worried - Molly doesn't know what her future holds and wishes the vote was to remain.
And what about the economy, asks Liz - "the pound's dropping, the euro is dropping".
After a long pause, she says: "I woke up today and I'm just sad."
Witney - shockwave for PM
The news that David Cameron is stepping down has sent a shockwave through his Witney constituency, writes Bethan Philips.
He has a lot of loyal supporters here.
He isn't a distant figure in Westminster - he is someone that campaigns here, gets involved in local issues, and during election time, goes door-to-door to gain support.
I was with one local Conservative activist as the news broke - he was visibly shaking with shock.
The big question now for Witney - will David Cameron stay on as MP, after he steps down as prime minister?
Northern Ireland - border worries
Those who experienced the "hard border" that existed between Northern Ireland and the Republic of Ireland during the Troubles will shudder at the memory of long queues of traffic as ID was checked and vehicles searched, writes Vincent Kearney.
On a bad day, the security checks could add a good hour to a round trip between Belfast and Dublin.
Some in the Remain camp argued that a vote to exit the EU would see a return of permanent border checkpoints.
Those in the Leave camp, including Secretary of State Theresa Villiers, insisted that was nonsense.
So what now?
The honest answer is that nobody quite knows.
Wales - 'class issue at play'
We have seen a very surprising pattern - working-class Labour voters going fairly solidly "Vote Leave", far more strongly than we were expecting, writes Vaughan Roderick.
Leave won Bridgend - which is First Minister Carwyn Jones' territory - and they won Rhondda Cynon Taff, which is Leanne Wood's home territory.
So maybe it is not the individual politicians we should be looking at - it is actually a question of income and social class more than political affiliation or political leadership.
Are we looking at a situation where people who felt they have had nothing to lose voted to leave, whereas people who feel they have something to lose - Labour or Conservative - decided to vote remain?