Betting markets that predicted Britain would remain in the European Union followed all the historical precedents of how undecided voters behave — and got it badly wrong.

On the eve of the referendum in which British voters shocked the world by choosing to abandon its 43-year-old membership in the EU (including its previous iterations), betting markets put the likelihood of that very outcome at nearly 1 in 4. Many voters who hadn’t yet taken a side, who went with the status quo in referenda in Scotland and Quebec, took the plunge.

“On the day the undecideds, of which there were many, went with their gut emotion,” said Leighton Vaughan Williams, a professor at Nottingham Trent University. “The markets were expecting the undecideds to switch predominantly to the status quo, as this has happened in previous referendums.”

Vaughan Williams also identified a crucial difference between Scotland’s referendum on independence in 2014 and the Brexit poll: The tabloid press in Britain raged against the EU and in favor of leaving.

“This time was different,” he said. “It was the Sun and Daily Mail that won it, and the impact these mass distribution tabloid papers have on the popular psyche, especially in whipping up emotion, is difficult to overestimate. It is another lesson learned.”

It’s difficult to measure the impact of the media on voters. But one unquestionable reason for the outcome is that the rank and file of the pro-EU Labour Party abandoned their elites en masse to put the "leave" camp over the top.

“‘Leave’ ap­pear to have tapped a deeper reser­voir of tra­di­tional Labour vot­ers than we might have pre­vi­ously as­sumed,” Pawel Swidlicki, a pol­icy an­a­lyst at Open Eu­rope, a think tank, told the Wall Street Journal.

Exit polls are spotty in Britain, but Labour stronghold after Labour stronghold began reporting majorities for leaving the EU when the votes were counted, giving pro-EU forces the jitters as soon as the polls closed.

The rebellion against the EU by traditional Labour voters also overlapped with a pronounced trend among Britons, the older they were, to support Brexit. A YouGov poll found that 75 percent of voters 18 to 24 voted to remain in the EU, while only 39 percent of those over 64 did.

“We didn’t mobilize our supporters to understand that this is not a protest vote against the government or the establishment,” former British Prime Minister Tony Blair told the Financial Times.

Blair called Labour’s support of the EU during the campaign “pretty lukewarm,” hinting at the trouble Labour leader Jeremy Corbyn now faces after the referendum. Corbyn came under repeated criticism for his halfhearted advocacy during the campaign, in which he repeatedly gave nods to the common criticisms of the EU, and may pay for the outcome with his job.

The problem for pro-EU forces extended to voter turnout as well, according to data compiled by the Press Association.

The overall turnout for the referendum was 72.2 percent, a very high number by the country’s standards. But three of the four regions with the lowest turnout — London, Northern Ireland and Scotland — were also strongholds of pro-EU sentiment. And those older voters who wanted to leave the EU turned out in higher numbers than younger ones.

Nigel Farage, leader of the anti-EU United Kingdom Independence Party, channeled precisely the sentiment — gut feelings — that Vaughan Williams identified after the result.

"I believe we're going to win this referendum. Why?” Farage told the BCC before the vote. “Because there's far more passion on the leave side of the argument.”