Britons at a “leave” party celebrate. Photo: Jack Taylor/Getty Images

The United Kingdom has voted to leave the European Union after 43 years, surprising analysts who predicted a close race but ultimately a victory for the “remain” side. Early results showed the two sides neck-and-neck, but, as results from more districts poured in, the “leave” side pulled away, and the BBC ultimately called the vote for “leave” at about 5 a.m. local time. Britain will be the first member to leave the 28-member union, and its departure could send shock waves throughout Europe.

With votes tallied in all 382 of the country’s voting districts plus parts of Northern Ireland, “leave” won by 52 percent to 48 percent for “remain.” The vote was reportedly called with 13.1 million votes counted in favor of Brexit and 12.2 million in favor of remaining in the EU.

Ahead of the vote, most analysts predicted the “remain” side would win out — indeed, British prime minister David Cameron would hardly have allowed the vote if he thought it would result in a Brexit — but anti-EU sentiment appears to have run unexpectedly strong in northern English cities hit hard by job losses after the 2008 financial crisis, according to the Associated Press. And although London and Scotland largely voted to remain in the European Union, they were overwhelmed by voters in Wales and the English shires, who largely voted in favor of the Brexit.

A poll conducted by YouGov suggests Britons voted along age-related fault lines as well, although it’s difficult to confirm whether actual voters followed this pattern, as the U.K. doesn’t conduct exit polls.

Not the official #Brexit vote but my god is this telling pic.twitter.com/adNC5R9Lu4 — Roberto Ferdman (@robferdman) June 24, 2016

On Friday, Cameron, who pulled for the U.K. to remain in the EU, announced he was stepping down as a result of the vote, despite calls from pro-“leave” members of his party such as Boris Johnson to stay no matter the outcome. “This is not a decision I’ve taken lightly, but I do believe it is in the national interest to have a period of stability and then the new leadership required,” he said. “I do not think it would be right for me to be the captain that steers our country to its next destination.”

In the aftermath of the vote, one expert told the AP that the “remain” campaign had suffered from “a degree of complacency,” and another said the campaign “failed to connect to ordinary people” and “seemed too much of an elite and London-based one.” Meanwhile, the campaign for the “leave” side played on British nationalism and a general feeling that the Establishment had proven ineffective. From the New York Times:

The campaign run by one of the loudest proponents of leaving, the U.K. Independence Party, or UKIP, flirted with xenophobia, nativism and what some of its critics considered racism. But the official, more mainstream Leave campaign also invoked immigration as an issue and its slogan, “Take control,” resonated with voters who feel that the government is failing to regulate the inflow of people from Europe and beyond. The British campaign featured assertions and allegations tossed around with little regard to the facts. Both sides played to emotion, and the most common emotion played upon was fear.

Britain’s actual divorce from the EU could take years, and some on the “leave” side (Johnson among them) have said it shouldn’t be completed until the country’s next general election in 2020. Cameron had previously said that, if the country voted to leave the EU, he’d move as quickly as possible to trigger an article of the Lisbon Treaty that would give the U.K. two years to negotiate its withdrawal.

Of course, there’s the chance the U.K.’s decision could fracture the EU, with other countries following Britain’s lead. Meanwhile, Scotland’s First Minister said the country’s decisive vote to remain means the country “sees its future as part of the EU” and could call its own independence referendum so as not to be ousted. The national chairman of Sinn Fein, Northern Ireland’s largest nationalist party, echoed her statements, saying the “British government as a direct result ha[s] forfeited any mandate to represent the interests of people here.” Other far-right leaders in countries such as France and the Netherlands have called for their own referendums as well.

“The main impact will be massive disorder in the EU system,” Thierry de Montbrial, founder of the French Institute of International Relations, told the Times. “There will be huge political transition costs on how to solve the British exit, and the risk of a domino effect or bank run from other countries that think of leaving.”

On the news of the vote’s outcome, the British pound tumbled to a 31-year low, and global markets fluctuated at historic rates as well. The yen rose 13 percent against the pound as investors scrambled for a safe haven, Japan halted trading, and the euro hit its lowest level in six years. The drop in European currencies lifted the U.S. dollar 3 percent, which, according to Reuters, is its biggest daily gain in nearly 40 years. Early projections predicted the DOW would open down 550 points, and Friday is likely to bring even more market tumult.

The British Pound has plummeted 9% and is trading at $1.36. It has not been this low since 1985. HT @charlesforelle pic.twitter.com/NBFG0xv6MZ — Dennis K. Berman (@dkberman) June 24, 2016

“All hell is breaking loose,” Vishnu Varathan, a senior economist in Singapore, told Bloomberg. “The only surefire is you buy yen, you buy U.S. Treasuries, you buy gold, and you sit tight.”

Nigel Farage, a strong proponent of the Brexit, was triumphant at Britain’s willingness to abandon the EU. “I now dare to dream that the dawn is coming up on an independent United Kingdom,” he tweeted, adding at a press conference: “If the predictions now are right, this will be a victory for real people … Let June 23 go down in our history as our independence day.”

This post has been updated throughout.