A joke among journalists is that we are taught to count: “one, two, trend.” But at this point, I think it’s fair to say that we are witnessing a populist trend around the world. The real question is, what is fueling its extraordinary rise?

Almost a month after Donald Trump’s election, Europeans went to the polls, with mixed results. Italians voted against everything — the establishment, the European Union and, by extension, their centrist, reform-minded prime minister, Matteo Renzi. Austrian voters, by contrast, rejected far-right candidate Norbert Hofer. But it was still startling that his Freedom Party — whose first leader was a former Nazi minister and SS member — received 46 percent of the national vote. Over the past few years, almost everywhere in Europe — including France, the Netherlands and Germany — right-wing populist parties have gained ground.

In most of the continent, populists still seem unlikely to take power because they cannot replicate Trump’s success in getting control of a mainstream political party. European parties are internally strong and have mechanisms to block such a hostile takeover. U.S. political parties, on the other hand, since the advent of primaries, have become nothing more than vessels for popular politicians. Once it was clear that Trump would win the Republican nomination, the party structure folded and became his executive arm.

Supporters of Trump and other populist movements often point to economics as the key to their success — the slow recovery, wage stagnation, the erosion of manufacturing jobs, rising inequality. These are clearly powerful contributing factors. But it is striking that we see right-wing populism in Sweden, which is doing well economically; in Germany, where manufacturing remains robust; and in France, where workers have many protections. Here in the United States, exit polls showed that the majority of voters who were most concerned about the economy cast their ballots for Hillary Clinton.

The one common factor present everywhere, however, is immigration. In fact, one statistical analysis of European Union countries found that more immigrants invariably means more populists. According to the study, if you extrapolate from current trends, “as the percentage of immigrants approaches approximately 22 percent, the percentage of right-wing populist voters exceeds 50 percent.” Hostility to immigration has been a core theme of every one of these populist parties.

One way to test this theory is to note that countries without large-scale immigration, such as Japan, have not seen the same rise of right-wing populism. Another interesting case is Spain, a country that has taken in many immigrants, but mostly Spanish-speaking Latinos, who are easier to assimilate. While you see traditional left-wing economic populism in Spain, you do not see right-wing nationalist movements.

The backlash against immigration is rooted in fact. As I pointed out in a Foreign Affairs essay (written in September, before Trump’s victory), we are living in an age of mass migration. In the past three or four decades, Western societies have seen large influxes of people from different lands and cultures. In 1970, foreign-born people made up less than 5 percent of the U.S. population; today they are about 14 percent. The rise is even sharper in most European countries, home to 76 million international migrants, recently coming mostly from Africa and the Middle East. Austria, for example, took in almost 100,000 immigrants last year — adding 1 percent to its population in 2015 alone.

This much change can be unsettling. For most of human history, people have lived, worked and died within a few miles of the place they were born. But in recent decades, hundreds of millions of people from poorer countries have moved to wealthier ones. This reflects an economic reality. Rich countries have declining birthrates and need labor; poor countries have millions who seek better lives. But this produces anxiety, unease and a cultural backlash that we are witnessing across the Western world.

What does this mean for the future? Western societies will have to better manage immigration. They should also place much greater emphasis on assimilation. Canada should be a role model. It has devised smart policies on both fronts, with high levels of (skilled) immigration, strong assimilation and no major recoil.

Eventually, Western societies will be able to adjust to this new feature of globalization. Look at young people in Europe and the United States, most of whom deeply value the benefits of diversity and seek to live in an open and connected world. That’s the future. We just have to ensure that we don’t wreck the world before we get there.