LONDON — In a stunning decision, Britain voted to leave the EU, according to BBC.

After a long night of back-and-forth totals, the country opted to become the first ever to leave the 28-member bloc. The result will most likely shock global markets and economies.

As results poured in through Thursday night and into the early hours of Friday, the “remain” camp became increasingly despairing, while “leave” advocates expressed a growing confidence that their side had pulled off a shocking victory.

The vote was expected to be tight, but throughout the night, results generally showed stronger-than-expected margins for those advocating a British exit – popularly known as Brexit.

The results came after 15 hours of voting, from the remote Scottish isles to the tip of Gibraltar. The referendum could reshape the country’s place in Europe and have economic, political and security implications around the globe.

The results also suggested that Britain may be even more deeply polarized than was previously thought, with huge gulfs between the views in thriving metropolitan centers such as London and those in struggling, post-industrial areas in other parts of England.

As local authorities announced results, they reflected a tantalizingly close vote that sent markets swinging wildly between optimism that the country would stay in, the preferred choice of investors, and pessimism that Britain had just voted to get out.

After initially rising, the pound plunged in international trading as jittery investors prepared for a scenario that had not been priced into market calculations.

As the hours ticked by, there was a dawning realization that Britain could be on the verge of becoming the first to leave the 28-member EU.

Bookmakers slashed their odds for “remain,” and political number-crunchers said that Britain appeared to be trending toward a decision to leave – although they cautioned that more data was needed from other parts of the country.

In television interviews, “remain” supporters looked stricken as they took in the results.

The pound’s sudden fall came only hours after it had surged to a 2016 high off news that an opinion poll conducted Thursday by the research firm YouGov showed “remain” with a four-point lead.

The results of that survey coincided with comments by anti-EU firebrand Nigel Farage, who told Sky News that it “looks like ‘remain’ will edge it,” suggesting he was ready for a loss.

Other “leave” leaders, however, refused to concede defeat. And with unexpectedly impressive showings for the “leave” campaign in the struggling northern English cities of Newcastle and Sunderland, it soon became clear that any hope of an easy victory for “remain” had evaporated.

Traditional strongholds of the Labour Party – which had backed the “in” side – looked particularly hard-hit by a pro-Brexit wave.

Among five polls released on the eve of the vote, two showed a lead for “in,” two gave the edge to “out,” and one forecast a tie. The final average of all polls on the day before the vote was 50-50, reflecting the too-close-to-call drama on one of the biggest questions to face Britain in decades.

Britain’s allies, as well as economists and investors worldwide, looked on with growing apprehension as Britain flirted with a choice that experts warned could lead to global market shocks and a rip in the Western alliance.

But millions of Britons demanded that their country declare independence from what many here regard as an oppressive Brussels bureaucracy that enables mass migration into the country.

The outcome will be a make-or-break moment for Prime Minister David Cameron, who campaigned vigorously for Britain to stay in the EU and cast the referendum as a choice between an insular, intolerant “little England” and an outward-looking, pluralistic Great Britain.

It is highly unlikely, however, that he achieved the goal he originally had when he called the referendum in 2013: to unite the country, and especially his Conservative Party, behind a common stance on an issue that has divided public opinion here for decades.

Instead of getting a resolution to the question once and for all, Cameron has been left with the raw wounds of a campaign that exposed more clearly than ever the fault lines in British society.

“It’s not going to be the settled will of the British people,” said Steven Fielding, a professor of political history at the University of Nottingham. “And for Cameron, that will create an instability and a threat.”

The threat comes from Cameron’s fellow Conservatives, many of whom openly defied him and led the push for Brexit. As the campaign’s rhetoric turned increasingly vitriolic, the prime minister found himself accusing former allies and close friends of lying to the British people; they replied in kind.

Cameron is widely expected to step down or be forced out. Even if it had gone his way, he would have faced hard choices over whether to purge the dissenters or welcome them back into his government.

If he is not able to bring his party back together, he could face a serious challenge to his hold on the keys at 10 Downing Street, with aggrieved backbench Tories already talking of a plot to oust him.

Any hopes of a coup may have encountered a setback Thursday night, when 84 pro-Brexit Tories in Parliament signed a letter saying they believed Cameron needed to stay on as prime minister – although they did not say for how long.

When Cameron first set a date for the vote back in February, he may have expected a relatively easy victory. But the campaign soon went off script, as Justice Secretary Michael Gove and then-London Mayor Boris Johnson – friends and sparring partners of Cameron’s since his days at Oxford – both declared their intention to campaign for “out.”

Soon afterward, the “leave” campaign found a compelling rallying cry with its call for voters to “Take Back Control,” a slogan that resonated among an electorate ill at ease with record levels of immigration – much of it from Europe under the EU’s free-movement policy.

But “leave” alienated some people with its reliance on what critics saw as increasingly nativist rhetoric. That was particularly true after the killing last week of pro-EU lawmaker Jo Cox, whose death appeared to awaken a passion in “remain” supporters that had been previously lacking, as well as a backlash against xenophobic aspects of the “leave” camp.

Still, the prevailing tone of the campaign on either side was fear and loathing, with neither side venturing for long into hope or aspiration.

That spirit mirrored the angry mood of voters across the Atlantic, in the United States, and surprised even close observers of a nation that sees itself as deeply pragmatic and rational.

“Notions of Britain as a deferential, consensual society at ease with itself have been thrown out the window,” Fielding said. “This campaign has revealed a very profound mistrust among a substantial segment of society toward conventional political authority. The EU became a lightning rod for mistrust of politics more broadly.”

The campaign split the country along essential lines: Old vs. young. Provincial vs. metropolitan. Scotland vs. England. Native-born Britons vs. immigrants.

Turnout on Thursday was considered heavy and was expected to be higher than during last year’s general election, when two-thirds of eligible Britons cast ballots.

In the small town of Birstall in West Yorkshire, voters streamed into a library outside of which, exactly a week ago, Cox was killed on her way to meet with constituents. A crowd of hundreds held hands during a minute of silence at 12:50 p.m. – the time of the attack – and chanted, “We stand together.”

Before Cox’s killing, “leave” had been surging in the polls. After the 41-year-old’s death – and the subsequent charging of a man with a long record of neo-Nazi connections who gave his name in court as “death to traitors, freedom for Britain” – the pendulum began to swing back.

As the first votes were cast Thursday morning – with the often-variable British weather running the gamut from a downpour in London to sunny, clear skies in Scotland – anxiety was the prevailing mood.

Hilary Clarke, a 45-year-old stay-at-home mother, was the first to vote at a southwest London polling station. She said she would use her stubby pencil to check “remain” on her ballot.

“If I had been confident, I wouldn’t be standing in the rain at 7 in the morning,” she said as she sheltered beneath a colorful umbrella. “The reason I’m first in the queue is I’m going straight to the airport to go to Barcelona, and I may not return if vote goes the wrong way.”

Clarke said she could not understand the logic of those pushing for “leave.”

“I can see that sometimes it seems we are hemorrhaging money to the EU,” she said. “But at the same time, we seem to get so much more back than we give. Even if you’re disagreeing with what’s said at the table, it’s better to have a place at it.”

But for “leave” voters, Britain’s four decades of membership in the EU and its precursors have only dragged the country down.

Andreas Hajialexandrou, a 48-year-old businessman of Greek Cypriot heritage, said the country could simply not withstand the impact of record numbers of immigrants from elsewhere in Europe.

“There are pressures on local services. I speak to our local doctors and they are just swamped,” he said. “The question is, how long can you support that level of immigration?”