Over the past few weeks, on the campaign trail and at home in the White House, President Trump has made it clear that attacking immigrants is the main thrust of his midterm message. In 2016, his anti-immigrant campaign resonated with his core supporters and it may well again in 2018, but this year more people have been turned off by the reality of his anti-immigrant politics. As a result, Mr. Trump’s vile strategy is more likely to backfire this time.

Mr. Trump’s anti-immigrant rhetoric has been escalating as Election Day nears. At every campaign rally, he unleashes on immigrants, spreading lies and fear, tweeting of the so-called caravan from Central America that “we cannot allow all of these people to invade our Country.” A few days ago in Nevada, he lied again when told a crowd that “illegal immigrants want to take over the control” of a California town. In their closing arguments, many Republican candidates are echoing Mr. Trump’s xenophobia and nativism.

Polling indicates this may not work that well in 2018 precisely because it is no longer merely campaign rhetoric. In the past two years, voters have had the chance to witness Mr. Trump’s rhetoric turn into severe anti-immigrant policies, leaving children as young as 12 months old parentless and alone in a government detention cell. He describes parents who are fleeing violence to seek asylum as “animals” and claims that violent gang members are “pouring into our country.”

Recent election results suggest that attacking immigrants no longer works with the majority that candidates need to win. Instead, a majority of Americans favor a more welcoming approach to immigrants, not divisiveness. Analysis of data from Virginia showed that the false claims of Ed Gillespie, the Republican candidate for governor in 2017, that the Central American prison gang MS-13 was threatening Virginia’s way of life moved voters away from his camp and actually made them more likely to vote for his Democratic opponent. In a special election for the House in a mostly white district in Pennsylvania, another Republican candidate, Rick Saccone, made bashing sanctuary cities central to his campaign, and he lost. Same outcome for Kim Guadagno in New Jersey, who lost the governor’s race badly while attacking immigrants. In the suburbs of Kansas City, Mo., Kevin Corlew ran a slew of anti-immigrant radio ads and lost a special election by 10 points. The list goes on.