WASHINGTON — Rep. Kevin McCarthy of California capped a meteoric rise through the ranks of power Thursday, winning election as House majority leader as Republicans shuffled their leadership in the wake of Rep. Eric Cantor’s primary defeat in Virginia.

Louisiana Rep. Steve Scalise, 48, was elected to replace McCarthy as whip, a clear indication that the rank and file wanted a red-state Republican in the upper ranks of leadership for the first time since the party gained control of the House in 2010.

McCarthy, a former aide who won his seat in Congress less than eight years ago, pledged after his victory to make sure the Republican Party “has the courage to lead with the wisdom to listen, and we’ll turn this country around.”

The changes take effect when Cantor steps down as majority leader on July 31. Cantor attended the day’s elections but did not speak as his successor was selected.

The challenges facing the leadership aren’t likely to change. They must guide an often fractious rank and file into the fall election season, while contending with a Democratic-controlled Senate and President Obama.

IMMIGRATION ISSUE

Within moments of McCarthy’s election, the League of United Latin American Citizens issued a statement calling on him to schedule a vote in the House on legislation to overhaul immigration law, including a path to citizenship for millions of immigrants currently living in the country illegally.

The issue has long divided Republicans and figured prominently in Cantor’s defeat a little more than a week ago, when he was trounced by David Brat, a little-known, underfunded tea party-backed challenger.

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.

At a news conference after the closed-door elections, Scalise and several Republicans stressed the party is united as it heads into the last several months of the year. They were at pains to project that image, as well, refusing even to provide the vote totals that might betray any internal division.

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 when Republicans took control of the House.

RYAN ON THE SIDELINES

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.