After losing his primary to tea party challenger David Brat, House Majority Leader Eric Cantor (R-Va.) announced he will be stepping down from House leadership at the end of July. (Associated Press)

After losing his primary to tea party challenger David Brat, House Majority Leader Eric Cantor (R-Va.) announced he will be stepping down from House leadership at the end of July. (Associated Press)

Majority Leader Eric I. Cantor (R-Va.) will step down from his leadership post at the end of July, ending a swift rise through the ranks of national politics and upending a leadership team that has run the House since Republicans took control after the 2010 tea party wave election.

Less than 24 hours after losing a primary contest to a tea party-backed economist, Cantor announced Wednesday afternoon that he will resign as leader July 31, but keep his seat until his term ends in January. He said that House Majority Whip Kevin McCarthy (R-Calif.) would make an “outstanding” successor.

“While I may have suffered a personal setback last night, I couldn’t be more optimistic about the future of this country,” Cantor told reporters Wednesday afternoon. “I’m honored that I’ve had the privilege of serving the people of Virginia’s 7th District.”

House Republicans plan to hold new leadership elections next Thursday, according to senior aides. In addition to McCarthy, several senior Republicans are mulling bids for top posts, so it wasn’t immediately clear which positions will be open next week.

(Live updates on the Cantor upset and its aftermath)

1 of 29 Full Screen Autoplay Close Skip Ad × A look back at Eric Cantor’s time in Congress View Photos The House majority leader was ousted by his primary opponent in a stunning loss Tuesday. Caption The House majority leader was ousted by his primary opponent in a stunning loss Tuesday. Sept. 27, 2008 Rep. Eric Cantor (R-Va.) holds up a statement by then-House Speaker Nancy Pelosi regarding a $700 billion financial rescue plan that failed to pass the House, as John A. Boehner (R-Ohio), who was the House minority leader, listens. Mark Wilson/Getty Images Buy Photo Wait 1 second to continue.

Speaker John A. Boehner (R-Ohio) led a Wednesday afternoon meeting of the House Republican conference and thanked Cantor and his staff for their service.

“This is a speech I never expected to give,” Boehner said. He was in tears later as Cantor addressed his 232 Republican colleagues.

Cantor’s decision to leave his leadership post after losing Tuesday to economist Dave Brat came on a day that Republicans began scrambling to build support and fill the leadership vacuum.

McCarthy, the next in line after Boehner and Cantor, is preparing to run for majority leader, but will have competition from more conservative colleagues.

Rep. Pete Sessions (R-Texas), chairman of the powerful House Rules Committee, began texting colleagues Tuesday night asking to speak with them about his bid for majority leader. His top advisers were actively positioning him for the race.

A confident Sessions predicted in an interview that he would beat McCarthy, arguing that his work to elect Republicans during the 2010 elections and his current leadership of powerful Rules Committee makes him ready to manage the House floor.

“I’ll be a majority leader who will be clear-headed about what we’re going to try to accomplish, putting more focus on what we’re trying to sell,” Sessions said, adding that he has a “strong and open” relationship with Boehner. “I know how to win.”

The large Texas Republican delegation, which represents 10 percent of the entire House Republican Conference, planned to meet later Wednesday with the possibility of producing a unified front for Sessions or Rep. Jeb Hensarling (R-Texas), chairman of the House Financial Services Committee, to be the Lone Star State’s favorite GOP son for a leadership slot.

It’s unclear when elections would be held to succeed Cantor, something that will be out of his control. Republicans aligned with more establishment figures privately expressed interest in shortening the race, for fear that a seven-week race until the end of July would be an ideological battlefield that tears the caucus apart.

Next week’s planned leadership elections will allow a transition period for Cantor and his staff to leave his post. Allies of the majority leader described the timing of July 31 as one based largely on helping his staff make their moves.

In addition to stepping down as majority leader, Cantor told colleagues Wednesday that he will not run as a write-in candidate in November.

Cantor returned to the Capitol Wednesday morning by sneaking into the building through a back door on the Senate side in hopes of avoiding reporters. He appeared stone-faced and tense, grimacing when asked by The Washington Post whether he would step down from his leadership post or resign from Congress.

Cantor, who has represented the Richmond suburbs since 2001, lost by 11 percentage points to Brat. The 51-year old had been considered the next generation’s GOP leader, who would take over for Boehner, 64,when he retired. In a caucus deeply divided between establishment Republicans and fire-breathing conservatives, these were the two who had shown some ability to keep order.

McCarthy hesitated even behind closed doors Wednesday morning to say he would run for majority leader, still stunned by the loss of his close friend, Cantor, according to aides not authorized to speak publicly about the unfolding leadership race.

McCarthy spent the morning in his spacious suite on the first floor of the Capitol, reaching out by telephone to more than 100 members, declining to go into details about his plans while hinting, with his appreciation for the encouragement, that he would run for majority leader. Later, he was seen huddling with several colleagues, including Reps. Christopher Smith (R-N.J.), Mark Sanford (R-S.C.), Mario Diaz-Balart (R-Fla.) and Dennis A. Ross (R-Fla.), as he tries to shore up support and avoid competition.

A race between McCarthy and Sessions would revive a long-simmering rivalry. They both ran for whip in 2010, with McCarthy besting his older opponent. Ever since, Sessions, 59, has been eager to challenge McCarthy and is telling colleagues that an older, more conservative hand is needed near the top, aides said.

With McCarthy seeking to climb the leadership ranks, Rep. Peter Roskam (R-Ill.), the chief deputy whip, announced to his inner circle Wednesday morning that he will run for whip, the third-highest position in leadership, and throw his support behind McCarthy as majority leader.

Roskam told The Washington Post that he would not comment out of respect to Cantor. He was seen heading to a meeting with his allies to discuss his path ahead.

But Roskam is expected to face competition from Rep. Steve Scalise (R-La.), who leads the conservative Republican Study Committee and is already privately whipping votes, and possibly Hensarling, according to aides familiar the jockeying.

In his conversations with colleagues, Scalise is making the case that he would serve as “a red state voice” in leadership ranks currently lacking a hardline conservative. Hensarling was seen huddling on the House floor Wednesday afternoon alongside House Budget Committee Chairman Paul Ryan (R-Wis.) and Rep. Tom Price (R-Ga.), a key conservative broker. Earlier, he had huddled with Reps. Mick Mulvaney (R-S.C.), Justin Amash (R-Mich.) and Raul Labrador (R-Idaho), a trio of renegade Republicans who rarely back leadership.

In a brief interview, Hensarling was coy, saying that he was still mulling a potential leadership run. But he was upbeat and smiling — somewhat unusual for the taciturn Republican — and enjoying the speculation.

Amid all the activity, Rep. Cathy McMorris Rodgers (R-Wash.), currently the fourth-ranking Republican as chairman of the House Republican Conference, said Wednesday that she wouldn’t be seeking a higher position, meaning the leadership contest will focus on the majority leader and whip jobs.

Boehner, meanwhile, appeared unfazed by the developments. He chatted Wednesday on the floor with close friends and avoided areas of the floor where McCarthy and others were chatting with colleagues. On Tuesday night, he stuck to his usual routine by hanging out with close friends and aides at an Italian restaurant that he likes near Capitol Hill.

The fast-paced developments left rank-and-file members stunned as the 233-member caucus began splintering off behind favored candidates.

Several conservatives said they were eager to see Cantor replaced by a southern conservative.

“I just think that there is a geographical area of the country that has not been represented in leadership and I think that could be the determining factor in what happens,” said Rep. Lynn Westmoreland, (R-Ga.).

Asked to further clarify which area of the country he thought the next majority leader should hail from, Westmoreland replied: “Get a map.”

But Rep. Pat Tiberi, an Ohio Republican close to Boehner, pushed back on suggestions that the next leader needs to be from the south.

“Where does it say that in the constitution?” he quipped to reporters.

Tiberi cautioned that the tea party success in ousting Cantor doesn’t necessarily signal an oncoming insurgence of conservatives into the GOP House leadership.

“I’ve been around this business for 14 years and I can’t remember when there hasn’t been an anti-Washington feeling,” he said.

Rep. Mo Brooks (R-Ala.) suggested that the GOP leadership team should have more equal political representation. “We need to have some people on there from red states as opposed to having all of them from blue states,” he told reporters.

Rep. Tim Huelskamp (R-Kan.), a frequent critic of Boehner and Cantor, said he hopes to elect a leader with deeper roots in the conservative base of the party.

“There’s a widespread concern about the Republican establishment not listening to conservatives and so I think it had energized the tea party,” he said. “It’s certainly not dead as we found out last night.”

Other colleagues, still shellshocked by Tuesday’s stunning turn of events, just expressed condolences.

“I’m sorry my friend lost,” said Rep. Tom Cole (R-Okla.).

Brat, meanwhile, appeared to struggle under fresh scrutiny of his upstart campaign. His campaign abruptly cancelled a scheduled news conference.

“Sorry, we’re kind of flying by the seat-of-our pants today,” a staffer said, explaining that the campaign decided to develop a media strategy before talking again to the press.

That decision came after Brat appeared on MSNBC to suggest that Cantor had lost touch with his district. Cantor “has not been present in the district,” he said.

“I was door-knocking, I know what was on the minds of the folks,” he added later.

But Brat appeared caught off guard by a barrage of policy questions. “I thought we were just going to chat today about the celebratory aspect,” he said.

Wesley Lowery, Jackie Kucinich and Sean Sullivan contributed to this report.