While in Tokyo earlier this month, I couldn’t help but notice how the city has changed. Where once it was rare to hear any language other than Japanese spoken on the street, now it happens constantly. Most of this is due to the huge tourism boom — more than 30 million people now visit Japan every year.

But obscured by that vast influx of guests is a longer-term trend. Tokyo is becoming a much more ethnically diverse city. I encountered black store clerks from the Netherlands and Africa, Chinese waiters at traditional Japanese restaurants, South Asian students staffing convenience stores, a white waitress at Starbucks, a Korean restaurant run by Southeast Asians.

These are anecdotes, but there’s data to back them up. In 2018, 1 out of 8 young people turning 20 in Tokyo wasn’t born in Japan. That doesn’t even count the people who were born in Japan but aren’t ethnically Japanese. Although Tokyo isn’t close to becoming a multiracial metropolis like New York City or London, the word “homogeneous” no longer fits the city.

Tokyo is an early harbinger of changes that are coming, albeit more slowly, to the rest of Japan. The capital’s diversity is in large part the result of Japan’s increasingly open stance toward immigration. Japan’s foreign-born population is still small compared to most other rich countries — a legacy of the highly restrictive attitudes and policies toward immigration that prevailed in past years. But since Shinzo Abe became prime minister at the end of 2012, the number of foreign-born people working in the country has expanded steadily.

The government reckons that there are now about 2.73 million non-Japanese living in the country — a 6.6 percent increase over the previous year, even as the overall population shrinks rapidly.

In recent years, the Abe administration has adopted major changes that will probably sustain the influx of immigrants. In 2017 Japan implemented fast-track permanent residency for skilled workers. In 2018 it passed a law that will greatly expand the number of blue-collar work visas, and — crucially — provide these workers with a path to permanent residency if they want it.

These changes thus represent true immigration, as opposed to temporary guest-worker policies (despite the common use of the term “guest worker law” to describe the new visas). In time, it will mean a more ethnically diverse Japanese citizenry. Permanent residents are allowed to apply for Japanese citizenship after five years. Some foreigners will also marry Japanese nationals, and their children will thus be citizens as well. Since the new law prevents visa holders from bringing families with them to Japan, many of the new workers will likely be single people looking for spouses, making them more likely to marry locals.

While this new immigration will help keep Japan’s economy and pension system afloat, it will inevitably introduce social strains. Unlike the United States, Canada and other nations whose populations are mainly a hodgepodge of the descendants of recent immigrants, Japan has little history of mass immigration. The one major recent episode of immigration was the movement of Koreans to Japan during the Japanese colonization of Korea and later during the Korean War. Due to Japan’s lack of birthright citizenship, the descendants of those immigrants have become a racialized minority, speaking no Korean but bearing Korean passports. Discrimination against these people, sometimes called Zainichi Koreans, was severe for decades, and though it has decreased substantially in recent years, a far-right fringe has emerged to persecute and slander the Zainichi.

Abe, despite being a conservative on foreign policy issues, has not tolerated these groups. In 2016 Japan passed its first law against hate speech, which is now being used to prosecute members of this group.

But the episode shows that Japanese society probably won’t be immune to the waves of nativist populism that have rocked Western countries in recent years. If even ethnic Koreans — who are generally physically indistinguishable from ethnic Japanese people — face persecution, people of visibly different racial groups may encounter even more.

An early sign of such tensions emerged in 2015, when a beauty pageant winner who was ethnically half Japanese and half black became the center of an online controversy, with some criticizing her for not being Japanese enough and others leaping to her defense. For now, the racial purists have generally been shouted down, and a half-Indian woman won the Miss World Japan pageant in 2016 with little backlash. But as the number of mixed and minority people in Japan becomes more prominent, the rightists can be expected to return with fresh rage.

More generally, Japan’s institutions are not used to coping with foreign and minority residents. Unlike in the U.S., where English as a second language classes are widely available, Japan has few classes to assist non-native speakers to catch up in Japanese fluency. Nor do Japanese cities have many official celebrations of immigrant culture or contributions.

So Japan is beginning a major and unprecedented exercise, similar in some ways to the experiments embarked on by many European countries. Japan is still far from being a diverse country, but it’s no longer quite right to call it homogeneous. The next two or three decades will reveal whether the country’s culture and institutions will be able to learn from Europe’s experience and manage a smooth transition, or whether immigration will spark a nativist backlash that closes the country off once again.

Noah Smith is a Bloomberg Opinion columnist and he blogs at Noahpinion.