House Majority Leader Eric Cantor (R-VA) announces that he will resign his leadership position in the House of Representatives on July 31, after having lost a primary race to Tea Party-backed college professor David Brat.WireImage

More On:

WASHINGTON — House Majority Leader Eric Cantor, stung by his startling GOP primary defeat, told colleagues Wednesday that he is stepping down from his leadership post at the end of July — setting off a feverish scramble among Republicans clamoring to fill the void.

Cantor’s exit will also leave open the fate of issues ranging from immigration reform to the next debt-ceiling crisis.

Although he backed away from budget negotiations with the administration in 2011, he later helped broker a deal to raise the debt ceiling and stave off a possible economic meltdown.

“In terms of getting anything done from a fiscal standpoint, it’s going to be difficult,” Cathy Roy, an investment officer at Calvert Investments, told Bloomberg News, lamenting the loss of the Virginia Republican in the next round of budget talks.

Immigration-reform advocates — including Mayor de Blasio — expressed concern that their task had just become much harder.

“I think it does not augur well for immigration reform, and we desperately need comprehensive immigration reform,” the mayor said during a press conference in Brooklyn.

Cantor was viewed as open to helping children of illegal immigrants, which his opponent used against him in the campaign.

Cantor announced his plans to step down as majority leader just hours after he was defeated by little-known Randolph-Macon College economics professor David Brat, who had strong Tea Party backing.

Adjusting to his nearly instantaneous lame-duck status, Cantor said he was giving up his powerful post with “great humility.”

As for his stunning election defeat, he was at a loss for an explanation. “I just came up short,” he told reporters.

In a closed-door meeting, Cantor threw his support behind Rep. Kevin McCarthy, the California lawmaker who is Republican whip, the No. 3 job. McCarthy is popular with colleagues but is gearing up to face a challenge from opponents considered more conservative than he is.

Colleagues were still reeling from the startling turn of events.

“I’m still trying to process this whole thing,” said Rep. Pat Tiberi (R-Ohio). “It was a real shock to me,” said Rep. Joe Wilson (R-SC).

Ambitious lawmakers began reaching out to promote their own leadership bids almost immediately after Cantor’s defeat was announced Tuesday night.