It should come as no surprise that the Trump administration has endorsed the Raise Act, a bill by Sens. Tom Cotton and David Perdue to reduce the number of legal immigrants to the U.S. while giving greater priority to highly skilled workers. Immigration reform drove President Trump to victory in 2016, and he is unlikely to drop it now.

Yet immigration has been—and remains—a key to America’s success. From colonial times, the country’s ability to integrate newcomers has facilitated its economic and technological achievement. From Alexander Hamilton to Albert Einstein to Steve Jobs, immigrants and their children have enhanced American dynamism, challenged American insularity, and played critical roles in developing American power.

But the public doesn’t always support a welcoming immigration policy. In 1924 the Johnson-Reed Act reduced legal immigration from the Old World by about 80%. Not even Hitler’s persecution of the Jews could persuade Americans to raise the quota.

Four factors turned the U.S. restrictionist in the 1920s. First, the numbers felt overwhelming. In 1910, almost 15% of American adults—3 in every 20—were foreign-born.

Second, the immigrants arriving in the early 20th century were overwhelmingly from Eastern and Southern Europe, rather than the traditional source countries in Northern Europe and the British Isles. This wave of migrants was seen as culturally alien and thus a challenge to American values and coherence. The native population’s fears amplified racism and xenophobia. The Ku Klux Klan, largely crushed by federal counterterrorism policies in the 1870s, was revived into a restrictionist force that was anti-Semitic and anti-Catholic as well as antiblack.

Third, economic uncertainty was already high. The Industrial Revolution was disrupting society. Family farms, the foundation of middle-class prosperity and security for generations, were failing nationwide. Inequality was rising, incomes for many in the middle class were stagnant or falling, and the new economy was more volatile and offered less security. Native-born rural Americans feared that immigrants would compete for jobs and depress wages, and that their political power would marginalize traditional American values and concerns.

Fourth, a small proportion of immigrants brought violent ideologies with them. Anarchist terrorists had attacked heads of state and political leaders around the world. Luigi Galleani, an Italian immigrant to the U.S., organized mainly other immigrants and inspired attacks—valorized as “propaganda of the deed”—against prominent people and institutions. His disciples were believed responsible for a 1920 Wall Street bombing that killed 38. Russia’s Bolshevik Revolution also sparked fears that immigrants might carry the “bacillus” of communism.

Do these factors sound familiar today? Immigration levels are at historic highs, the cultural gap between immigrants and the native population is wide, the economic outlook for many Americans is troubled, and a (very) small number of immigrants sympathize with horrific ideologies abroad. A fifth and serious additional factor, not paralleled in the early 20th century, is the presence of millions of illegal immigrants. As Mr. Trump understood, illegal immigration corrodes public sympathy for high levels of legal immigration.

Meanwhile, some of the classic arguments in favor of immigration may need to be re-examined. If automation will destroy millions of routine jobs in the next decade, how much unskilled labor does the U.S. require?

Nevertheless, America still needs immigrants. Their talent and dynamism are more vital than ever. If U.S. companies want to maintain their technological edge and profitability in a competitive world, they need skilled immigrant workers. Immigrants create jobs and industries, making the future brighter for all Americans, while paying into the country’s hard-pressed social-insurance system.

Yet history suggests that when public opinion sours on immigration, policy eventually follows. Now that process may be getting under way. Public dissatisfaction with the relatively liberal immigration policies in place helped drive the 2016 election. The Raise Act is provocative, perhaps intentionally so. But giving greater priority to highly skilled immigrants, while reducing total numbers, might secure the many benefits of a liberal immigration regime while reducing the political fallout. Properly designed, a new system might offer Silicon Valley and other employers better access to the specialized professionals they need, while also addressing the politically potent concerns of Mr. Trump’s populist base.

America’s ability to welcome and integrate immigrants remains one of its strengths, but history suggests that a dogmatic insistence on the current policy may well stoke an anti-immigrant backlash. It is more prudent to accommodate these concerns than to defy them.

Mr. Mead is a fellow at the Hudson Institute and a professor of foreign affairs at Bard College,