To determine how immigration shaped electoral fortunes, we examined the link between voters’ views on immigration and whether they voted Democratic or Republican in 2016. We then compared the strength of that link with recent elections in which immigration was less visible as a national campaign issue. We estimated whether voters supported the Democratic or Republican candidate on the basis of their preferred level of immigration — “increase,” “keep the same,” “decrease” — taking into account the voter’s party identification, ideology, gender, age and level of education.

We found that Mr. Trump did only slightly better than his Republican predecessors among anti-immigration whites. Among pro-immigration whites, however, Mrs. Clinton far outpaced John Kerry in 2004 and Barack Obama in 2008 and 2012. For example, Mr. Obama received the votes of 50 percent of pro-immigration whites in 2012, whereas Mrs. Clinton won the votes of 72 percent of that group in 2016 — a 22-point difference.

Among anti-immigration whites, by contrast, Mr. Trump improved only marginally on Mitt Romney’s showing, 79 percent to 71 percent. Perhaps most important — given the popularity of the “keep the same” position — is that immigration moderates swung 7 percentage points in Mrs. Clinton’s favor (Mr. Obama received 38 percent to Mrs. Clinton’s 45). The 2016 comparisons with 2008 and 2004 are highly similar.