The study, published in the International Journal of Forecasting, shows that gamblers sensed the Leave vote coming an hour before the currency experts in the city -- creating a window of "arbitrage" during which the price difference between betting and foreign exchange markets yielded up to a seven per cent return on the pound.
Economists from the University of Cambridge in the UK compared the behaviours of the Betfair betting market and the sterling-dollar exchange rate from closure of the polls at 10pm, when odds of 10 to 1 were being offered on Brexit.
Both markets were "informationally inefficient": very slow to react despite the data already available, as well as that flooding in from vote counts across the country.
This meant there was money to be made by trading early on either market, researchers said.
The study shows the betting market moved to a Leave result around 3am, by which time Brexit odds had reversed (1 to 10).
Yet the foreign exchange market didn't fully adjust to the reality of Brexit until around 4 am. At 4:40 am the BBC predicted a Leave victory.
The difference in efficiency between the two markets created an hour when selling One pound and hedging the result of the referendum on Betfair would have made up to nine cents of profit per pound sterling -- a significant "unleveraged return" that, in theory at least, could have seen astute traders make millions.
Researchers say the findings support the idea that gambling, or so-called "prediction markets", might provide better forecasts of election outcomes than either experts or polls.
"Clearly, punters trading on Betfair are a different group of people to those dealing in FX for international finance. It looks like the gamblers had a better sense that Leave could win, or that it could at least go either way," said Tom Auld, lead author of the study.
"Our findings suggest that participants across both markets suffered a behavioural bias as the results unfolded. Initially, both traders and gamblers could not believe the UK was voting to leave the EU, but this disbelief lingered far longer in the city," Auld said.
Auld and his co-author Oliver Linton used the expected outcomes for each voting area -- data that was publicly available prior to the referendum -- to create a "forecasting model".
By adjusting it with each actual result in turn, they say that their model would have predicted the final result from around 1:30am had it been deployed on the night.
"According to theories such as the 'efficient market hypothesis', the markets discount all publicly available information, so you cannot get an edge on the market with data already out there," said Auld.
"However, using data publicly available at the time we show that the financial markets were very inefficient, and should have predicted Brexit possibly over two hours before they actually did," he said.
"If there is a second referendum, the vote should be better understood by markets -- in line with a theoretical concept called the adaptive markets hypothesis. Studies such as ours will mean that market participants will be primed to profit from any possible opportunities and inefficiencies," he said.
The researchers compared their modelling with gambling and currency market data from EU referendum night.
The website Betfair provided data from their exchange platform -- the world's largest betting exchange -- between 10am on June 23 and 5am on June 24.