To many people around the world, the United Kingdom’s vote, on Thursday, to quit the European Union came as a great shock. But the result, with fifty-two per cent of voters in favor leaving the E.U., shouldn't have been such a surprise. The fact is, the E.U. has never been particularly popular with ordinary people in the U.K., particularly England, and in the weeks leading up to the vote many opinion polls showed the Leave side with a narrow lead. The financial markets and most commentators, myself included, were assuming that, at the last minute, prudence and risk aversion would generate a swing in favor of Remain. That didn't happen.

The easiest way to understand what did happen is to look at some voting maps. With the exceptions of London, Scotland, and Northern Ireland, every major region of the U.K. voted to exit the E.U. The Remain vote was particularly weak in the West Midlands and the Northeast of England, two areas that have been hit hard by de-industrialization. But even in the relatively prosperous Southeast of the country, if you subtract London from the results, a majority of people voted to leave.

The Guardian has published some telling charts detailing the demographic breakdown of the vote. For one thing, they show gaping class divisions. One of the best predictors of how people voted was their education level. Those with college degrees tended to opt for Remain, while people without them tended to opt for Leave. Age and income gradients were also clearly visible in the vote tabulations. The older and poorer you are, the more likely you were to vote Leave. The younger and richer you are, the more likely you were to vote Remain.

Put all this data together, and the implication is that, outside of Scotland and Northern Ireland, which are special cases, the British working classes and lower middle classes, particularly those living in the provinces, have delivered a stinging rebuke to the London-based political establishment, which was largely in favor of staying in the E.U. But what explains this revolt against the élites?

One popular theory points to racism and nativism, which featured prominently in the anti-E.U. campaign. The Leave side went up in the polls after it managed to shift the debate away from the likely economic impact of Brexit and onto immigration and issues of national sovereignty. Although much of the immigration into the U.K. comes from outside of the E.U., the Leave forces were able to focus attention on the freedom of movement for workers, which is one of the founding principles of the E.U.

In the past decade or so, Britain has taken in many thousands of immigrants from Poland, Romania, and other Eastern European countries that joined the European community after the Berlin Wall came down. In many working-class areas of the U.K., there is a lot of resentment toward these new arrivals, who are viewed as competitors for jobs and government-provided services, such as education, health care, and welfare. "A majority of people thought immigration is too large, and that leaving the E.U. would bring it down," John Curtice, a political scientist at Strathclyde University who is also the BBC's resident polling guru, said on-air on Thursday, as the results came in.

A second theory, which I examined in a post on Thursday, is that economic anxieties and resentments underpinned the political anger that fuelled the Leave vote. Demagogues such as Nigel Farage, the leader of the U.K. Independence Party, were able to exploit these economic worries, directing them against immigrants and other easy targets.

Yet another argument is that the Leave result was really about culture and values. Pointing to data collected by the British Election Study, Eric Kaufmann, a professor of politics at Birkbeck College, argued on Friday that the best predictor of voting patterns wasn't income or education levels but attitudes toward the death penalty, which are a proxy for authoritarian attitudes more generally. "The probability of voting Brexit rises from around 20 per cent for those most opposed to the death penalty to 70 per cent for those most in favour," Kaufman wrote on the Web site of the Fabian Society. "Wealthy people who back capital punishment back Brexit. Poor folk who oppose the death penalty support Remain."

This is an interesting theory, but it doesn't necessarily explain why hostility toward the E.U. has risen in the U.K. during the past couple of decades. Has the British public become more authoritarian and resistant to change during that period? I don't think so; if anything, attitudes about gay marriage and other social issues show a shift in a liberal direction.

What has certainly happened is that decades of globalization, deregulation, and policy changes that favored the wealthy have left Britain a more unequal place, with vast regional disparities. "It's the shape of our long lasting and deeply entrenched national geographic inequality that drove differences in voting patterns," Torsten Bell, the director of the Resolution Foundation, a bipartisan think tank, commented on Friday morning. "The legacy of increased national inequality in the 1980s, the heavy concentration of those costs in certain areas, and our collective failure to address it has more to say about what happened last night than shorter term considerations from the financial crisis or changed migration flows."

That argument sounds persuasive to me. On Thursday night, it was the early announcement of a huge Leave vote in Sunderland, a depressed city in the Northeast that used to be a big shipbuilding center, that indicated the way the night was headed and caused the pound sterling to plummet in the Asian markets. Meanwhile, the Remain vote was consistently stronger in prosperous areas. Economics matters.

Still, the margin of victory was narrow, and it is also worth looking at the way the Leave and Remain campaigns were run, and considering how things could have turned out differently. If the Remain side, led by Prime Minister David Cameron, had managed to persuade two in a hundred more voters to accept its arguments, it would have won. But the Remain campaign was uninspiring in the extreme.

In retrospect, it can be argued that Cameron’s mistake occurred as far back as 2013, when, in an effort to satisfy the Eurosceptics inside his own Conservative Party, he pledged to hold a referendum at some point before 2017. At the time, this was an easy promise to make: Cameron believed he couldn't deliver on it. He was then heading a coalition government alongside the pro-E.U. Liberal Democrats, who wanted no part of a referendum and had the power to veto one. But after the Conservatives pulled off a surprise in the May, 2015, general election and won a majority in the House of Commons, the Prime Minister felt he had no option but to follow through on his promise.

Yet even after he had set a date for the referendum, Cameron could surely have done a better job of selling an upbeat vision of the E.U., one that had Britain as an active and enthusiastic member. Rather than accentuating the positive, Cameron and George Osborne, the Chancellor of the Exchequer, sought to scare the electorate into voting their way, arguing that a vote for Leave would plunge the U.K. economy into a recession and cost the average household about sixty-two hundred dollars a year.