WASHINGTON (AP) — House Republicans chose relative moderate Rep. Kevin McCarthy as their next No. 2 leader Thursday, trying to unite and quickly move past the internal party turmoil that began with the shocking defeat of the current second-in-command in a primary election.

In a widely expected outcome, McCarthy of California defeated the more conservative Rep. Raul Labrador of Idaho for the position of majority leader in a secret ballot.

The Republican shake-up began with Majority Leader Eric Cantor's unexpected loss in Virginia's primary last week to a far-right candidate backed by the limited-government tea party movement. Cantor quickly announced he would step down as majority leader on July 31, setting off the scramble for leadership jobs.

The challenges facing the leadership aren't likely to change. They must guide an often fractious rank and file into congressional elections this November, while contending with a Democratic-controlled Senate and President Barack Obama.

Republican restiveness along ideological and regional lines was on full display as members of the House of Representatives lawmakers met privately to elect their leadership lineup for the rest of this year.

Labrador had been supported by some House Republicans who argued that Cantor's defeat showed the need for the party to take a new, more conservative direction. But McCarthy's knack for helping colleagues get elected and his ability to maintain a personal connection quickly gave him the advantage as he emerged as the front-runner.

A more competitive race took place to replace McCarthy as majority whip, the No. 3 position in the House. That race was won by Louisiana Rep. Steve Scalise — a clear indication that the rank and file wanted a Republican from a deeply conservative state in the upper ranks of leadership for the first time since the party gained control of the House in 2010.

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 a week ago, when he was trounced David Brat, a little-known, underfunded tea party-backed challenger.

In setting quick elections, the leader of the House, Speaker John Boehner, and other Republican 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.

Many Republicans said now was a time for calm.

"Given the way Cantor is going out, it's important to show a little bit of stability," said Congressman John Campbell, who said he backed McCarthy.

___

Associated Press writers Alan Fram, David Espo and Erica Werner contributed to this report.