Britain’s stunning vote Thursday to leave the European Union was part of a dramatic internal struggle over the country’s identity, culture and independence that will transform its role in the world for the foreseeable future.

It will undoubtedly cause economic pain for its citizens while likely sparking a fresh Scottish referendum on independence, as well as a possible reassessment within Northern Ireland of its place in the United Kingdom.

The Brexit vote may turn out to have been a blunder of historic proportions: Instead of affirming Britain’s identity and independence, it could tear the country apart.

Americans would be wrong to see this as a faraway dispute with no bearing on our own politics. In the United States, demagoguery, populism and the stoking of nationalist fears are also winning hearts and minds – as well as votes for presumptive Republican presidential candidate Donald Trump. His popularity is rooted in anger and frustration – and those emotions are not only felt on the right.

A different sort of dissatisfaction – but dissatisfaction nonetheless – propelled Sen. Bernie Sanders’ improbably strong showing in the Democratic race.

Does this reflect a failure of democracy or of politics? Maybe a little of both. Elections are the foundation of a democratic system, and even when voters opt for a path that is contrary to their best interests, they need to be respected. It is through elections that competing visions and, yes, grievances, are mediated.

Yet the Brexit vote also points up just how much work needs to be done by those who believe in a society that is pluralistic, pro-free-trade, non-isolationist and pro-immigration.

The skeptical need to be persuaded and the disengaged need to be brought into the process.