WASHINGTON (AP) — Rep. Kevin McCarthy of California, a former aide elected to Congress in his own right less than eight years ago, won election as House majority leader Thursday as fellow Republicans shuffled their leadership in the wake of Rep. Eric Cantor’s primary defeat in Virginia.

McCarthy, 49, triumphed over Rep. Raul Labrador of Idaho to continue his extraordinarily rapid rise through the ranks. The totals of the secret ballot election were not immediately disclosed.

McCarthy has been serving as his party’s whip, or chief vote counter. His ascension set up a three-way election to fill his current spot in the leadership, involving Reps. Steve Scalise of Louisiana, Peter Roskam of Illinois and Marlin Stutzman of Indiana.

The elections followed a brief campaign set in motion little more than a week ago, when Cantor, the current majority leader, lost a primary election to little-known, underfunded tea party-backed challenger David Brat.

In setting quick elections, Speaker John Boehner and other leaders hoped to avoid a drawn-out, divisive struggle that might complicate the party’s drive to retain its majority in midterm balloting on Nov. 4.

Yet the timing of the day’s events made it unclear whether the winners — or perhaps Boehner, himself — might face fresh challenges when the rank and file gathers in the fall after national elections.

McCarthy, moved quickly to line up the votes for majority leader in the wake of Cantor’s defeat at the polls in Virginia, deploying an organization developed since he became whip more than three years ago when Republicans took control of the House.

One potential rival, Rep. Paul Ryan of Wisconsin, decided against joining the race, while another, Rep. Jeb Hensarling of Texas, deferred to a second Texan, Rep. Pete Sessions. Sessions quickly dropped out, though, saying it was obvious that a successful campaign would have created painful divisions within the party.

Rep. Raul Labrador of Idaho jumped in, but by then, the California front-runner had amassed support from across the rank and file. He was aided not only by personal ties, but by the fundraising prowess he has displayed since joining the leadership.

His Majority Committee PAC gave nearly $1.2 million to Republican House candidates and organizations during the two-year election cycle of 2011-2012, and an additional $480,000 to candidates so far in advance of this fall’s balloting.

If McCarthy’s ascension seemed a foregone conclusion, the battle to take his whip’s spot was anything but — so much so that there was speculation that a second ballot might be required to settle the contest.

Congressional leadership races are traditionally contests that turn on personal relationships, geographical considerations, ideology and more. Inside the current GOP rank-and-file, moderates needed not apply. Instead, the various candidates stressed their conservative credentials.

Roskam, 52, a fourth-termer who is currently chief deputy whip, sought to move up the leadership ladder among a group of politicians that often prefers breaking precedent rather than following it. Additionally, his rivals cited a need to install a red-state Republican in the top tier of leadership that so far lacks one.

Scalise, 48, who won his seat in a special election in 2008, fit the bill, and campaigned as head of the Republican Study Conference, a group of that sometimes serves as a conservative thorn in the side of leadership.

Stutzman, 37, a second-term lawmaker, also reached out to tea party-backed lawmakers. He joined the race at a time it appeared that Scalise was having trouble gaining enough votes to defeat Roskam.