Repudiated at the polls, House Majority Leader Eric Cantor announced Wednesday that he will resign his leadership post at the end of next month, clearing the way for a Republican shake-up five months before midterm elections.

Cantor informed fellow Republicans of his intentions at an emotional closed-door meeting, then made his public announcement at a news conference where he appeared upbeat, all less than 24 hours after losing a primary election to David Brat, a little-known and underfunded rival backed by tea party groups.

Lawmakers in both parties said Cantor’s defeat and the prospect of a change within the Republican high command probably signal the demise of immigration legislation and will also have a negative impact on the balance of President Barack Obama’s second-term agenda.

Even so, White House spokesman Josh Earnest disputed the notion that Cantor’s surprise loss crushed the prospects of House Republican leaders putting an immigration bill on the floor this year.

He noted that Sen. Lindsey Graham, R-S.C., had been deeply involved in passing the Senate immigration bill and still defeated his primary opponents Tuesday night.

The outcome of Tuesday’s primary represented the biggest victory by far this year for tea party forces, and it holds the potential to unsettle other incumbents facing GOP challengers this summer. The next major showdown is a June 24 runoff between six-term Sen. Thad Cochran of Mississippi and his rival, state Sen. Chris McDaniel.

In the House, Republicans set leadership elections for June 19, assuring that any Capitol Hill campaigning will be brief. House Speaker John Boehner, R-Ohio, issued an appeal for cohesiveness at the closed-door meeting where he praised Cantor. “This is the time for unity, the time for focus,” he said in remarks released by his office.

Even before Cantor’s announcement, jockeying had broken out among fellow Republicans eager to move up the House leadership ladder — or establish a foothold on it.

Rep. Kevin McCarthy of California, the party whip and third-ranking leader, informed fellow Republicans he intended to run to succeed Cantor. Rep. Pete Sessions of Texas also made clear his interest, but fellow Texan Jeb Hensarling eyed a candidacy as well, and the state’s delegation was working to prevent any intramural competition.

Rep. Paul Ryan, R-Wis. and the party’s 2012 vice presidential candidate, ruled out a leadership bid.

Cantor, 51, sounded like anything but a man ready to retire from politics, saying he will serve out his term and be active this fall for Republican candidates.

“What divides Republicans pales in comparison to what divides us as conservatives from the left and their Democratic” allies, he said.

Accused by tea party critics of being too accommodating on immigration and other issues, and criticized by Democrats for being inflexible, Cantor said he had struck the right balance. “I think that this town should be about trying to strike common ground,” he said.

But one Republican said he feared the effects of Cantor’s defeat could be debilitating for the party and the government.

Interviewed on MSNBC, Rep. Peter King, R-N.Y., said he was worried that Cantor’s stunning loss may lead to even more congressional gridlock. Asked if he thought immigration legislation was dead, he replied, “I’m concerned that Ted Cruz supporters, Rand Paul supporters, are going to use this as an excuse” to shut down the government.

“This is not conservatism to me,” King said. “Shutting down the government is not being conservative.”

The resignation would mark a swift end to a quick rise to power for Cantor, 51, who was elected to Congress in 2000, was appointed to the leadership two years later, and then rose steadily to become the second-most powerful Republican in the House. In that post, he was the most powerful Jewish Republican in Congress, and occasionally was seen as a potential rival to Boehner but more often as a likely successor.

Brat campaigned as a foe of immigration legislation, and said Cantor was likely to help immigrants living in the United States illegally gain amnesty if given a new term in the House.

Interviewed on MSNBC, Brat declined to spell out any policy specifics.

“I’m a Ph.D. in economics, and so you analyze every situation uniquely,” he said.

Brat begins the fall campaign as a decided favorite in the race against Democratic rival Jack Trammell in a solidly Republican Richmond-area district.

(story can end here)

The impact of Cantor’s surprise loss on the fate of immigration legislation in the current Congress seemed clear. Conservatives will now be emboldened in their opposition to legislation to create a path to citizenship for immigrants living in the country illegally, and party leaders who are sympathetic to such legislation will likely be less willing to try.

Cantor has compiled a solidly conservative voting record in his tenure, but he was sometimes viewed with suspicion by tea party activists who said he had been in Congress too long and was insufficiently committed to blocking immigration legislation. Many party officials argue that Republicans must temper their hard line on immigration if they are to compete effectively in future presidential elections.

Already on Wednesday, Hillary Rodham Clinton, a potential Democratic contender, said Cantor “was defeated by a candidate who basically ran against immigrants.”