Regardless of the exact reason for Mr. Cantor’s defeat, the news media’s focus on immigration is likely to deter Republicans from supporting comprehensive immigration reform. It could even discourage Republican presidential candidates in 2016, when the party will need to broaden its appeal to Hispanic voters in states like Florida.

There were very few pre-election polls, though one survey conducted for the Daily Caller by Vox Populi, a new Republican firm, showed Mr. Cantor just over 50 percent and ahead by 12 points. News media accounts suggested that Mr. Cantor’s campaign was confident, and one internal poll showed he had a 34-point advantage.

Mr. Cantor’s loss is not likely to endanger the Republican hold on his district. Mitt Romney won the district by 15 points in 2012, and it is not at all apparent that Mr. Brat is the sort of fatally flawed candidate who could lose such a Republican district. After all, he defeated Mr. Cantor.