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 along the lines President Barack Obama is seeking and will also have a negative impact on the balance of his 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.
Cantor also has been deeply involved in GOP attempts to develop an alternative to the health care law that Republicans want to repeal.
Fellow Republicans set leadership elections for June 19, assuring that any campaigning would be brief.
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. Peter Roskam of Illinois, the chief deputy whip, and Rep. Steve Scalise of Louisiana quickly jumped into the expected race to succeed McCarthy.
Rep. Paul Ryan, R-Wis. and the party's 2012 vice presidential candidate, ruled out a leadership race.
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 Speaker John 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.
His primary triumph was by far the biggest of the 2014 campaign season for tea party forces, although last week they forced veteran Mississippi Sen. Thad Cochran into a June 24 runoff and they hope state Sen. Chris McDaniel will achieve victory then.
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."
Democrats, underdogs in the struggle for control of the House this fall, sought to cast Cantor's defeat as evidence that the Republican Party and tea party groups were one.
"The Republican Party has been completely swallowed by the tea party. I mean, any debate over whether the tea party controls the Republican Party has ended," Rep. Debbie Wasserman Schultz of Florida, the Democratic national chair, said on MSNBC.
At the closed door meeting, Boehner praised Cantor and urged the rank and file to remain cohesive.
This is the time for unity, the time for focus," he said, according to one official in the room. "Focus on the thing we all know to be true: The failure of Barack Obama's policies and our obligation to show the American people we offer them not just a viable alternative, but a better future."
Associated Press writers Andrew Taylor, Alan Fram and Erica Werner in Washington contributed to this report.