Before the vote in Virginia, pundits on both the right and left were speculating that Mr. Gillespie’s anti-immigrant strategy was working. But in the end, election results and polling data in Virginia proved all that thinking was wrong. While each state has its own demographics and distinct politics, Virginia has voters who span demographic and economic spectrums. Majorities of voters of all races and ethnicities rejected anti-immigrant stereotypes as ugly and wrong.

According to an election eve survey of voters by Latino Decisions, Latino voters said that Mr. Gillespie’s MS-13 ads made them less enthusiastic about him, by a 45-point margin. But it wasn’t just Latino voters. By a 23-point margin (52 to 29), whites in Virginia also said the MS-13 ads turned them away from Mr. Gillespie, as did African-American and Asian-American voters by larger margins.

Data speaks louder than punditry, and our regression analysis of survey data paints a clear picture. Exposure to Mr. Gillespie’s MS-13 ads actually helped drive white college-educated voters away from the Republicans. When we analyzed findings for white independents and Republicans, voters who were aware of the MS-13 ads were significantly more likely to vote for Mr. Gillespie’s Democratic opponent. What should be alarming for Republicans is that this effect wasn’t limited to the governor’s race. The Gillespie campaign had coattail effects, but of the wrong stripe. Across all racial groups, those who were aware of Mr. Gillespie’s MS-13 ads were significantly more likely to vote for Democratic candidates for Virginia’s House of Delegates.

This means that not only is it morally just for Democrats to position themselves as the party that stands against hatred and bigotry and in favor of inclusiveness and opportunity, but it is also a strategically sound position for winning votes. Simultaneously, it sends a clear, welcoming message to Latino, African-American and Asian-American voters, while also winning over enough of the white voters who also oppose immigrant bashing.

This phenomenon is particularly true of voters who will decide crucial House and Senate races in 2018: people of color and white college-educated voters — also known as the Democratic base. Mr. Trump and his fellow Republicans are clearly gearing up for a similar anti-immigrant effort in 2018. But now the mask has been pulled off. Voters get it. Democrats have an opportunity to speak out strongly against bigotry. And in doing so, they have a path to victory in 2018 and beyond.