LONDON — Britain has voted to leave the European Union, stunning global financial markets and sending a seismic shock through the Continent.

The pound suffered its worst day in more than 30 years, plunging downward, as Dow Industrials futures and other markets prepared for a huge jolt to the global financial system.

British Prime Minister David Cameron resigned early this morning. The humiliating defeat is a stunning reversal of fortune for Cameron, who called the referendum himself and confidently expected to win. Cameron was returned to office with a surprise overall majority amid scenes of Conservative jubilation in the general election just over a year ago.

A leading anti-European Union campaigner, who had earlier said he expected to lose the referendum, reappeared as dawn broke over Britain to claim a dramatic victory.

“Let June 23rd go down in history as our Independence Day,” shouted Nigel Farage, leader of the U.K. Independence Party, with both arms held aloft.

As he spoke, billions of pounds were already being drained from the British economy.

It was a tumultuous end to an extraordinary day in which thunderous storms and floodwater lashed Britain as the nation faced up to its most profound decision in a generation.

Despite a strong showing for the Remain campaign in London and Scotland, the majority of Britons voted decisively to quit the EU. With almost all of the results counted, Leave was heading toward a 52 percent to 48 percent victory.

Arguments about loss of sovereignty and loss of border control trumped the grave economic forecasts.

The markets’ reaction to the result was swift. The euro dropped to its lowest point since it was launched in 1999, London’s FTSE futrues fell, and the pound suffered an unprecedented slump. But the contagion was not limited to Europe; Dow futures buckled, the price of oil fell, and the Asian markets suffered such heavy losses that the Nikkei temporarily halted trading.

As the markets crashed around him, Cameron was also plunged into a constitutional crisis. Amid his resignation as prime minister, members of the Leave campaign that crushed him in the referendum are asking him to stay in post to try and ease instability. He’s expected to stay in office for several months.

The First Minister of Scotland said there must now be a second Scottish referendum as citizens north of the border had voted to Remain in the European Union, while Sinn Fein claimed the British government had now “forfeited any mandate” to represent Northern Ireland.

The crisis had seemed so unlikely when the polls closed at 10 p.m. in Britain (5 p.m. ET). There were no exit polls because polling companies said they would be unable to accurately predict the result in an unprecedented vote. Pollsters YouGov published a projection based on a survey of 5,000 people taken on polling day. That model estimated that Remain was ahead by 52 percent to Leave’s 48 percent.

Farage’s early pessimism was based on the YouGov numbers, but also reports that turnout has been very high despite the rainstorms. The Leave campaign expected that a smaller electorate would be more likely to vote for Britain to exit the EU, which has become known as Brexit.

As soon as the first real vote counts were announced, it became clear that the pollsters’ forecasts had been wrong yet again.

Newcastle, a vibrant city in the northeast, was the first to announce its results; a strong expected win for Remain was slashed to a narrow 2-point victory. An even more dramatic shock followed in neighboring Sunderland, a grittier former industrial center. The Leave campaign was hoping for a double-digit victory there, but that was blown away by a stunning 22-point margin.

Flash floods had earlier submerged roads and landslides closed railway lines, leaving commuters in and around London battling the elements in order to make it to the polling booth. Some of those made it only to discover that their polling station had been forced to close due to floodwaters.

It was crucial for Remain to stack up millions of votes in the capital, but turnout was lower in the inner-city areas where the Remain vote was strongest.

The campaign on Britain’s membership of the European Union has been bruising. It’s driven a new faultline through public life; Conservatives have been pitched against Conservatives, Labour against Labour, fathers and mothers against their sons and daughters.

The assassination of Jo Cox, a young pro-Europe member of parliament, who was allegedly shot dead at close range by a far-right radical, transformed the final week of the campaign into a deeply bitter fight as both sides accused the other of politicizing her death.

Although most are still rightly confused about what exactly would happen if Britain voted to leave the European Union, it was obvious that this decision is far more important than a general election.

As Britons woke Friday morning to see their economy teetering, they will be forced to face the reality in stark terms.

For months, friends and neighbors have been thrust into heated political arguments for the first time in decades. That is likely to continue as Britain strives to negotiate a new future outside the European Union.

Cameron, who gambled his own political future as well as the health of Europe’s economies on a referendum that he believed he would win comfortably, is not expected to last long in his job despite assurances that he would stay on to oversee the negotiation period.

“If his party do persuade him to stay on, his authority is completely gone. I would have thought that any sense of self-respect would make him want to go,” said Sir Vince Cable, a Liberal Democrat minister in Cameron’s last government. “I feel that his day is now gone.”

Cameron’s resignation would automatically trigger a Conservative Party leadership contest, but not a general election. The next Tory leader would move into No. 10 Downing Street, but would be under huge pressure to ask the public to give them consent in an election soon afterward.

Britain is one of the central pillars of a pan-European union that was forged in the embers of the Second World War. It was initially reluctant to commit, but signed up in 1973 after another bitterly divisive referendum. Britain’s decision to quit risks the prospect of the entire union collapsing as nations like Sweden, Italy, and Greece ponder their own referenda.

London’s financial markets have been in turmoil amid the uncertainty. As opinion polls lurched toward a Leave vote this month, $150 billion was wiped off the value of Britain’s biggest companies in just four days.

The markets recovered many of those losses in the lead up to polling day, which meant a Remain victory was priced into the market and they were totally unprepared for what was to follow.

So was Britain.