House majority leader Eric Cantor was defeated Tuesday night in the Republican primary for his House seat in Virginia—a truly shocking political loss in every sense of the word. Quite literally nobody in the political arena saw this coming, apparently including the challenger himself, Dave Brat, a professor of economics at Randolph-Macon College. He wouldn’t give a victory speech “until he was sure it was real,” according to Fox News host Megyn Kelly during the network’s Tuesday night broadcast.

The immediate question is obviously: How did this happen? How did one of the most powerful Republicans in Congress lose to a political neophyte that he outspent 26-to-1?

In politics, there’s a rush to find “the answer.” There’s no one reason why Cantor lost, but a crucial part of the story no doubt begins in Central America.

In recent months, tens of thousands of children unaccompanied by their parents have been flooding across the US border with Mexico. Sixty thousand will come this year, up tenfold from 2011, and as many as 130,000 may arrive in 2015. Lackland Air Force Base in Texas is filling up with these refugees, one of three military bases now being used to house the new arrivals. President Obama has declared it an “urgent humanitarian situation.”

The situation has gotten light to moderate coverage in the mainstream press, but in the right-wing press the coverage has been wall to wall: it has been relentlessly covered by online outlets like Breitbart News, and talked about incessantly on right-wing radio. Fox News has also devoted considerable attention to the crisis; the night before the Virginia primary, for example, Kelly had a long segment about it on her prime-time show.

Naturally, the right-wing concern isn’t exactly driven by a humanitarian spirit. The overwhelming message is that the influx—which will indeed cost taxpayers millions of dollars—is not only a harbinger of things to come but a direct result of Obama’s desire for immigration reform. Specifically, goes the narrative, Obama’s promise of a DREAM Act that would confer citizenship on undocumented youth is spurring the stampede.

This is mainly nonsense: for one, the proposed DREAM Act would apply only to youth living continuously in the United States for five years before enactment. Though right-wing outlets like the Drudge Report have found immigrants here and there aware of the bill and hopeful that it might apply to them, by and large analysts agree that increasing violence in Central America is driving parents to send their children to safer areas in large numbers. Escalating drug wars in Mexico and improved US economic conditions are making the United States the obvious landing spot for the northward-bound refugees.

But this all came at a terrible time for Cantor. His biggest foray into the immigration debate was to propose and draft a Republican version of the DREAM Act dubbed the KIDS Act. The bill stalled out late last year, in part over disagreements about whether youth who obtained citizenship would be able to then sponsor their parents for legalization.

So you can see where this is going. Brat was already running hard against Cantor for supposed softness on immigration. He employed an effective approach: instead of coming at it from an unhinged, xenophobic and divisive position, Brat played the populist. He charged that Cantor was a tight friend of Wall Street, the US Chamber of Commerce—another broad theme of Brat’s campaign—and that Cantor’s alleged desire for immigration reform was done so his buddies in the corporate world could employ more cheap labor.

In recent weeks, as the right-wing media fulminated over the refugee crisis, Brat took out the sledgehammer. One ad cooked up by the campaign, released this week, charged directly that “tens of thousands of illegal immigrants are pouring across the border on the promise of Eric Cantor’s amnesty”:

That’s naturally a wild distortion of what’s happening, and the presentation is amateurish in the extreme. (It badly misspells ‘Reuters’ at one point.) But if you’re looking for a reason Cantor suddenly fell, attacks like that could be the answer. “Closing the border is very important,” Brat told Sean Hannity on Tuesday night after his victory. “I ran hard on that issue.”

Now for all the necessary caveats: this was a House race where fewer than 100,000 people voted, and so it’s perhaps unwise to draw broad political lessons. Conservative activists made a convincing case Tuesday night that Cantor’s strong-arming of Tea Party types during state-level political meetings and conventions boiled grassroots anger, which also surely contributed to his loss.

Another caveat is that other pro-immigration Republicans, like Senator Lindsey Graham, won their contests. It should be noted, however, that Graham had some uniquely feckless opponents who did not attack him on immigration with the same zeal as Brat, nor were they as polished. The second-place finisher to Graham in Tuesday’s primary wants South Carolina to mint it’s own currency and compared the IRS to Nazi brownshirts.

It’s also true that Cantor made a sharp right turn on immigration and was basically an ally of anti-reform Republicans: he didn’t push for any of the very modest bills passed out of committee to come to the floor, and just last month he blocked a measure sponsored by a fellow Republican that would have given citizenship to undocumented US service members.

But in politics, perception is reality. Cantor was perceived as soft on immigration by many right-wingers, and may have lost because of it. The perception that he lost for that reason, in turn, will terrify Republicans for even dipping a toe in the reform waters.

One could say the GOP had already decided not to act on immigration any time soon, which might be true. But that intransigence, which perhaps could have been softened by midterm election results or external dynamics, has now only been hardened. Immigration has “been off the table for a while but now it’s really never going back on the table,” a lawmaker close to the House Republican leadership told Buzzfeed Tuesday night. “No one who wants to be in leadership eventually will ever, ever go for it and likely raise holy hell if it comes up.”