WASHINGTON — In one of the most stunning primary election upsets in congressional history, the House majority leader, Eric Cantor, Republican of Virginia, was soundly defeated on Tuesday by a Tea Party-backed economics professor who had hammered him for being insufficiently conservative.
Mr. Cantor’s defeat delivered a major jolt to the Republican Party — he had widely been considered the top candidate to succeed Speaker John A. Boehner one day — and it has the potential both to change the debate in Washington on immigration and to reshape the midterm elections, which had been favoring his party.
With just over $200,000, David Brat — a professor at Randolph-Macon College in Ashland, Va. — toppled Mr. Cantor, repeatedly criticizing him for being soft on immigration and contending that he supported what critics call amnesty for immigrants in the country illegally. The Associated Press declared Mr. Brat the winner.
Going into the elections, most Republicans had been watching for how broad Mr. Cantor’s victory would be, with almost no one predicting that he would lose.
Mr. Cantor’s defeat — the most unexpected of a congressional leader in recent memory — will reverberate in the capital and could have major implications for an immigration overhaul.
Mr. Cantor, who is in his seventh term, had sought to rebut Mr. Brat’s charges on immigration, using some of his $5.4 million to send fliers and air television ads in which he claimed to oppose an “amnesty” policy. But with significant help from conservative talk radio figures such as Laura Ingraham, Mr. Brat was able to galvanize opposition to Mr. Cantor in one of Virginia’s most conservative congressional districts.
Mr. Cantor’s loss recalled the defeat of former Speaker Thomas S. Foley, a Democrat who lost to a little-known Republican, George Nethercutt, in the 1994 general elections that delivered control of Congress to the Republicans. It is extremely rare for a member of the congressional leadership to lose a primary.
Mr. Cantor had won primary elections in his district around Richmond, Va. — which stretches more than 100 miles from the Tidewater region nearly to the Washington suburbs — with as much as 79 percent of the vote, and he won his race for a sixth term with 58 percent. He was not seen as vulnerable in this cycle.
Within the Republican Party, he was seen as a star, with the ability to tap into the energy of the House’s more conservative members while at the same time not alienating the party’s establishment wing.
In the House, his relationship with Mr. Boehner reflected some of the larger tensions within the party. Mr. Cantor was strongly opposed, for instance, to the so-called grand bargain budget negotiations between the speaker and President Obama.
Mr. Brat had significant help from people like Ms. Ingraham, who helped reinforce his position on immigration, a message that resonated particularly with the more rural voters in the district.
Mr. Cantor, 51, received what amounted to a warning shot from local Republicans at a district convention last month in Henrico County, his political home base, when conservatives ousted one of his loyalists as Republican chairman while he looked on.
Yet he seemed to recognize the seriousness of the threat only in the final weeks of the campaign, when he suddenly shifted his advertising and began sending aides from Washington to his district. At that point, it was too late to stave off defeat.
In addition to Mr. Brat’s criticism that Mr. Cantor was insufficiently conservative, Mr. Cantor faced anger in his district for the perception that he was too detached from the area. While he kept a home in the Richmond area and sent his children to school there, he spent much of his time in recent years traveling across the country to raise money and campaign for Republican candidates.
It was all part of a longstanding ambition to become speaker of the House on the part of a politician who began his career as the youthful driver to his predecessor, Representative Thomas J. Bliley Jr. Reaching that pinnacle had, of late, seemed as close as ever, with Washington full of speculation that Mr. Boehner would soon retire.
“I’m in shock,” said Representative Patrick T. McHenry, Republican of North Carolina, expressing the mood on Capitol Hill.
Cantor was part of the team that led the G.O.P. to victory in 2010 and the mastermind of a young-guns program that propelled the very sort of Tea Party candidate who ultimately spelled his doom. He was the original friend of freshman Republicans who, against the wishes of Mr. Boehner, resisted raising the debt ceiling and other deals.
With Mr. Cantor gone from the leadership suites, David Wasserman, an editor at the nonpartisan Cook Political Report, predicted “a free-for-all” when House Republicans assemble after the November elections to pick their new leaders. At the very least, Representative Kevin McCarthy of California, the No. 3 Republican, will seek to move up to majority leader, but he could also challenge Mr. Boehner.
More broadly, Mr. Cantor’s defeat will embolden conservatives like Representative Tom Price, Republican of Georgia, who has openly complained that the leadership positions are occupied by Democratic or swing-state Republicans. The push will be for “red state” leadership.
Candidates could include Mr. Price, Representative Jeb Hensarling of Texas, and brash newcomers like Representative Tom Graves of Georgia, Mr. Wasserman said. The message is that the House must be run by more conservative leaders.