Britain has voted to leave the European Union after a bitterly divisive referendum campaign, toppling the David Cameron government, sending global markets plunging Friday and shattering the stability of a project in continental unity designed half a century ago to prevent another world war.

The decision raises the likelihood of years of negotiations over trade, business and political links with what will become a 27-nation bloc. In essence, the vote marks the start — rather than the end — of a process that could take decades to unwind.

Markets plunged as results defied bookmakers' odds to show a 52-48 per cent victory for the campaign to leave a bloc that Britain joined more than 40 years ago.

The results have also raised the possibility of one or more breakups within the U.K. as nationalist politicians in Scotland and Northern Ireland — where voters favoured remaining within the EU — say a Brexit warrants a vote on independence for their constituents.

An emotional Cameron, who led the Remain campaign to defeat, losing the gamble he took when he promised the referendum in 2013, said he would leave office by October.

"The British people have made the very clear decision to take a different path and as such I think the country requires fresh leadership to take it in this direction," he said in a televised address outside his residence.

"I do not think it would be right for me to be the captain that steers our country to its next destination," he added, choking back tears before walking back through 10 Downing Street's black door with his arm around his wife Samantha.

Cameron resigns, Farage pleased, Boris Johnson thanks British people 1:15

Economists predict recession

Quitting the EU could cost Britain access to the EU's trade barrier-free single market and means it must seek new trade accords with countries around the world. A poll of economists by Reuters predicted Britain was likelier than not to fall into recession within a year.

The EU for its part will be economically and politically damaged, facing the departure of a member with its biggest financial centre, a UN Security Council veto, a powerful army and nuclear weapons.

The world's biggest trading bloc — which rose out of the ashes of two world wars, fascist and communist totalitarianism to unite a continent of prosperous democracies — will lose around a sixth of its economic output.

"It's an explosive shock. At stake is the break up pure and simple of the union," French Prime Minister Manuel Valls said. "Now is the time to invent another Europe."

The vote had a turnout of 72 per cent of the more than 46 million registered voters.

People react to a regional EU referendum result. (Jack Taylor/Getty Images)

'A noble idea'

Former London mayor Boris Johnson, a leading voice in the Leave campaign and a potential successor to Cameron, on Friday lauded the outgoing PM as a "brave and principled man."

Johnson, who left his home to jeers from a crowd in the mainly pro-EU capital, said Britain will continue to be a "great European power."

"We cannot turn our backs on Europe. We are part of Europe," Johnson said.

"But there is simply no need in the 21st century to be part of a federal system of government based in Brussels … It was a noble idea for its time. It is no longer right for this country."

The result emboldened euro-skeptics in other member states, with French National Front leader Marine Le Pen and Dutch far-right leader Geert Wilders demanding their countries also hold referendums. Le Pen changed her Twitter profile picture to a Union Jack and declared "Victory for freedom!"

The vote will trigger at least two years of divorce proceedings with the EU, the first exit by any member state. Cameron, in office since 2010, said it would be up to his successor to formally start the exit process

Former London mayor Boris Johnson and his wife Marina are photographed after voting in the EU referendum in London. (Matt Dunham/Associated Press)

Euphoria for euroskeptics

Lawmakers from the opposition Labour Party also launched a no-confidence motion to topple their leader, leftist Jeremy Corbyn, accused by opponents in the party of campaigning only tepidly for its Remain stance.

There was euphoria among Britain's euroskeptic forces, claiming a victory over the political establishment, big business and foreign leaders including U.S. President Barack Obama who had urged Britain to stay in.

"Let June 23 go down in our history as our independence day," said Nigel Farage, leader of the euroskeptic U.K. Independence Party, describing the EU as "doomed" and "dying."

On the continent, politicians reacted with dismay.

German Chancellor Angela Merkel, who invited the French and Italian leaders to Berlin to discuss future steps, called it a watershed for European unification. Her foreign minister called it a sad day for Britain and Europe

The shock hits a European bloc already reeling from a eurozone debt crisis, unprecedented mass migration and confrontation with Russia over Ukraine. Anti-immigrant and anti-EU parties have been surging across the continent, loosening the grip of the establishment that has governed Europe for generations.

Comments from EU, Germany, France and Donald Trump 1:24

Accusations of scare-mongering

Britain has always been ambivalent about its relations with the rest of post-war Europe. A firm supporter of free trade, tearing down internal economic barriers and expanding the EU to take in ex-communist eastern states, it opted out of joining the euro single currency or the Schengen border-free zone.

Cameron's ruling Conservatives in particular have harboured a vocal anti-EU wing for generations, and it was partly to silence such figures that he called the referendum.

Back then it looked like a sure thing. But the 11th hour decision of Johnson — Cameron's schoolmate from the same elite private boarding school — to come down on the side of Leave gave the exit campaign a credible voice.

The four-month campaign was among the most divisive ever waged in Britain, with accusations of lying and scare-mongering on both sides and rows over immigration which critics said at times unleashed overt racism.

At the darkest hour, a pro-EU member of parliament was stabbed and shot to death in the street. The suspect later told a court his name was "Death to traitors, freedom for Britain."

The front page of the Sun newspaper, reporting on the EU referendum, celebrated the results with this celestial image. (Tim Ireland/AP)

The result triggers a new series of negotiations that is expected to last two years or more as Britain and the EU search for a way to separate economies that have become intertwined since the U.K. joined the bloc on Jan. 1, 1973. Until those talks are completed, Britain will remain a member of the EU.

Exiting the EU involves taking the unprecedented step of invoking Article 50 of the EU's governing treaty. While Greenland left an earlier, more limited version of the bloc in 1985, no country has ever invoked Article 50, so there is no road map for how the process will work.

"It will usher in a lengthy and possibly protracted period of acute economic uncertainty about the U.K.'s trading arrangements," said Daniel Vernazza, the U.K. economist at UniCredit.

The European Union is the world's biggest economy and the U.K.'s most important trading partner, accounting for 45 per cent of exports and 53 per cent of imports.