Shortly after the results of Britain’s Brexit referendum were announced, CNN interviewed a visibly shaken Tony Blair, who did his best to explain why a narrow majority of British voters had decided to leave the European Union. There was something poignant about Blair’s reaction, which managed to be calm, measured, and anguished all at the same time. One gets the sense Blair understands, on a gut level, that Britain’s rejection of the EU is a rejection of his worldview. Perhaps he can take some solace in the fact that he is not alone.

Like most leading figures in the worlds of politics and business, Blair favored remaining in the European Union. As prime minister during the 1990s, he often made the case for deeper European integration. More broadly, Blair proved himself to be among the most emphatically cosmopolitan world leaders in recent history. Within the Labour Party, Blair has since been repudiated by a base that fiercely rejects his brand of economic liberalism and will never forgive him for his decision to back the war in Iraq. Both commitments were, in very different ways, a reflection of Blair’s belief in a more internationalist Britain, one that would shed its imperial past and embrace a new one as a multicultural society at home in the world.

To that end, Blair also presided over the opening of Britain’s borders to immigrants. Since 1997, when the Labour Party, under his leadership, swept into office in a landslide, British society has been transformed by a wave of immigration unprecedented in its history. Over the following years, roughly twice as many immigrants arrived in the United Kingdom as had arrived in the previous half-century. Many who arrived during that earlier era hailed from the Caribbean and South Asia, and by the early 1990s, 7 percent of England and Wales’ population belonged to ethnic minorities. By now, that share has grown to over 14 percent. This, more than anything else, has been Tony Blair’s legacy, and it is a legacy his successors Gordon Brown and David Cameron have been grappling with ever since.

In Britain’s less-diverse, pre-Blair past, political conflict was more or less straightforwardly driven by class conflict. The Tories were the party of the rich, the shires, and the aspirational working class, while Labour represented the working class and a thick slice of Britain’s credentialed professionals. Class still matters in post-Blair Britain, but so too does the widening divide between cosmopolitans who embrace Britain’s post-Blair transformation and nationalists who do not. David Cameron has long tried to straddle this divide: The EU referendum’s result is a testament to his failure.

To understand Britain’s demographic transformation, it is important to understand that it has been unevenly distributed. Immigrants and their children have long been heavily concentrated in London, and southeastern England, and a handful of cities in the Midlands. London in particular feels ever more like a post-national metropolis. The white Britons who live there today are generally those most comfortable with cosmopolitanism and ethnocultural diversity. Those who’ve left are generally less so. Over the past decade, however, members of ethnic minority populations have been settling outside of Britain’s urban centers in ever-larger numbers. Eric Kaufmann, a scholar of nationalism and its relationship to demographic change, observed that the white British population is particularly sensitive to the rate of immigration. When an immigrant influx is relatively gradual, resistance to immigration is limited. When it occurs very rapidly, the level of resistance intensifies and support for explicitly anti-immigration parties like the U.K. Independence Party (UKIP) increases.

What does this have to do with the European Union? One of the EU’s core principles is freedom of movement: EU citizens have the right to live and work in any EU member state. When a number of countries in Eastern and central Europe joined the EU, most existing member states put temporary limits in place on the freedom of movement to ensure they wouldn’t experience a large and potentially disruptive influx of new arrivals. Blair’s government decided not to do so on the assumption that immigration from the new member states would be relatively modest. In fact, immigration from the new member states far surpassed the government’s projections.

It was around this time that the politics of immigration in Britain entered a new phase. Ever since the 1960s, when large-scale Commonwealth immigration sparked intense controversy, the Conservatives have been seen as the more anti-immigration party. And during the Blair years, Conservatives struggled to shake their image as narrow-minded bigots. Just over three-fourths of the immigrants who’ve arrived in Britain since 1990 have been from outside the European Union; among the British elite, at least, anti-immigration sentiment has long been seen as a proxy for racism against nonwhites.

In more recent years, however, the challenges presented by mass European immigration complicated this neat picture of the prejudiced Conservative. Early on, David Cameron recognized that doubts about uncontrolled immigration were no longer limited to older white traditionalists who could be dismissed, fairly or otherwise, as motivated by racial resentment. Once the less-skilled immigrants at the heart of the immigration debate were Poles and Bulgarians rather than blacks and South Asians, one could more credibly argue that anti-immigration sentiment was driven by concerns about the fiscal and environmental impacts of immigration, not a blind hatred of outsiders.

And the last decade or so has indeed seen Britain become a highly sought-after destination for less-skilled European immigrants, thanks to the structure of the U.K.’s economy and its public policies. Recently, Martin Ruhs, an expert on international labor migration based at Oxford University, argued that free movement across the European Union is greatly complicated by the fact that different member states have different approaches to labor market regulation and the welfare state. First, countries with lightly regulated labor markets are generally more attractive to less-skilled immigrants than countries with tightly regulated labor markets, because high minimum wages and rigid limits on work hours tend to price less-skilled workers, native- or foreign-born, out of jobs. This is why there are so many less-skilled, non-European immigrants desperate to enter Britain from France—a country no less prosperous or safe than Britain— where it is far harder for immigrants to get on the labor market’s bottom rungs.

Second, there are some European countries with welfare states that demand years of contributions before one can start drawing benefits and others where prior contributions are not generally required. Less-skilled immigrants to countries with noncontributory welfare states can start drawing benefits fairly quickly, regardless of their contribution. Britain is one such country: Under Tony Blair, Britain greatly expanded the use of refundable tax credits as a tool for poverty reduction, and this strategy has been wildly successful. But under EU rules, Hungarian newcomers are just as entitled to these benefits as, say, a poor Welshman. Regardless of whether this is a good idea, it is easy to see why some Britons find it frustrating. The only way Britain can make itself less attractive to less-skilled European immigrants is by imposing labor market regulations and welfare reforms that would apply to everyone, including less-skilled British workers. If we’re going to curb welfare spending, some British voters are asking, why not start with European immigrants who’ve just showed up on our doorstep? If the European Union requires Britons and other EU citizens be treated the same, why not leave the EU and be done with it?

As opposition leader, and later as prime minister, Cameron did much to legitimize doubts about mass immigration. He also pledged to drastically reduce net migration to the U.K. on explicitly nonracial grounds. The trouble is that while Britain could restrict non-European immigration, it could not limit European immigration without flouting EU rules. Since Cameron came to power in 2010, European immigration as a share of total immigration has crept upward for precisely this reason. Europe’s economic malaise and Britain’s robust labor market recovery has made it all but impossible for Cameron to hit his overly ambitious immigration targets.

Recognizing that his failure on immigration made him vulnerable, Cameron tried desperately to persuade other member states to allow Britain to change the rules. But he met with implacable resistance from the leaders of newer member states in central and Eastern Europe, who resented the suggestion that their citizens be treated any differently than Britons. This left Cameron dangerously exposed: Having made the case for why Britain should have more control over European immigration, Cameron’s failure to actually wrest that control from his European partners made him look more than a little ridiculous. All leading Brexiteers like Boris Johnson and Michael Gove had to do was point out that Cameron had failed to deliver.

Right now, the partisans of “Remain” are damning the likes of Johnson and Gove for Brexit. However, it is not at all clear if they are the ones to blame for Remain’s defeat. Had Cameron managed to secure a solid commitment from the European Union to do something as simple as limit the access European immigrants had to British welfare state benefits for, say, two or three years, Remain almost certainly would have won.* Instead, Cameron’s friends and allies in Europe left him out to dry.

What will Britain look like in the wake of Brexit? One possibility is that it will be awfully similar. If Britain leaves the EU merely to become a member of the looser and more-inclusive European Economic Area, it may well be subject to the same freedom of movement rules—while having even less say over Europewide policies. Or perhaps Britain will truly attempt to forge its own path in the name of Corbyn-ite socialism or UKIP–style populism. The only thing we can safely say is that the Blair era has finally and definitively come to a close.

*Update, June 24, 2016: This sentence has been updated to clarify that although Cameron failed to secure the four-year ban on benefits for EU migrants he had sought, other EU member states did promise to work with him on phasing in in-work benefits. (Return.)

Read more Slate coverage of the Brexit vote.