Cantor fought back, boasting in strongly worded mailers of shutting down plans to grant "amnesty" to "illegal aliens" — a changed tone for a lawmaker who'd spoken out in favor of citizenship for immigrants brought illegally to this country as youths.
He hardened his stance on the policy, moving to block House action last month on a GOP-authored measure offering citizenship to certain immigrants here illegally who serve in the military.
It wasn't enough.
After a primary election season in which immigration had barely registered, the outcome suggested that it can still be a potent political issue for Republican primary voters.
And Cantor's loss almost certainly ended whatever slim hopes remained for a deal on immigration in the House this year, likely putting the issue on ice until after the 2016 presidential election.
"It's really dead now," said Roy Beck, president of Numbers USA, a group that opposes comprehensive immigration legislation. Immigration "has been pronounced dead many times over the last two years, but I think the voters of Cantor's district have sent an incredible message."
Some immigration advocates and pollsters cautioned it was too soon to say whether immigration was the deciding factor for Cantor. David Winston, a GOP pollster who advises House Republicans, said that had Cantor known he was truly threatened, he would have campaigned differently, possibly producing a different outcome. Instead, Cantor's internal polling had shown him comfortably ahead.
"Was that the key issue? We don't know because the candidate never thought he was in a race," Winston said.
Immigration advocates also noted that some GOP candidates who embraced immigration legislation escaped their primaries unscathed. Sen. Lindsey Graham, R-S.C., an author of the comprehensive immigration bill that passed the Senate last year, won his primary handily Tuesday.
Another House member, Rep. Renee Ellmers, R-N.C., also won last month even though her opponent attacked her as a supporter of relaxing immigration laws.
Some Democrats were still holding out hope for action. "Now Mr. Cantor can do the right thing instead of the political thing," said Rep. Joe Garcia, D-Fla.
But Cantor's loss was such a stunning rebuke for a politician seen as next in line to be speaker of the House that it immediately emboldened conservative opponents of immigration legislation.
For a Republican House rank and file already reluctant to take on the politically volatile issue in an election year, the outcome offered an object lesson on the benefits of steering clear.
And for establishment Republicans who've been pushing support for an immigration overhaul as the best way for the GOP to win back the Latino voters crucial to national elections, Tuesday's result was a sobering setback. In the year since the Senate passed a comprehensive immigration bill, House Republicans have resisted the entreaties of the business community, religious leaders and the GOP establishment.