Washington (CNN) Rep. Kevin McCarthy was elected House minority leader Wednesday in a closed-door meeting of House Republicans, putting the California Republican in position to lead House GOP members after Speaker Paul Ryan leaves Capitol Hill at the end of his term in January.

The vote was 159-43. McCarthy had faced a long-shot challenge from Rep. Jim Jordan of Ohio, the co-founder of the conservative Freedom Caucus.

With Ryan headed for the exit s, McCarthy, the current No. 2 House Republican, had long been viewed as the heavy favorite to become minority leader in the new Congress, the highest-ranking GOP leadership post with Republicans in the minority after losing control of the House of Representatives in the midterm elections.

Ryan announced in April that he would not seek re-election and had endorsed McCarthy , the House majority leader for the past four years, to be his successor.

Rep. Steve Scalise of Louisiana, the current No. 3 House Republican, was elected to the No. 2 Republican leadership position in the new Congress, where he will serve as minority whip. Rep. Liz Cheney of Wyoming, the daughter of former Vice President Dick Cheney, was elected to the third-ranking position in the GOP hierarchy and will be the next Republican conference chair.

At a news conference Wednesday, McCarthy vowed to help the GOP win back the majority in the House and said Republicans will oppose Democrats if they target President Donald Trump.

"We will work with anybody across that aisle if they are there to work to move America forward. But let me be very clear, if their agenda is simply investigations, impeachment, and not focused on the hardworking American public, we will be there to defend the American public," McCarthy said.

Trump and McCarthy have spoken about leadership races recently, territory that Presidents usually avoid so not as to seem like they're alienating members of their own party. In private conversations, the President pushed for Jordan and another close conservative ally -- Rep. Mark Meadows of North Carolina -- to have the top Republican positions on key committees, according to a source familiar. McCarthy doesn't dole out those positions -- that's for the House GOP Steering Committee -- but plenty of people on the Steering Committee are loyal to McCarthy and would heed his word. As of Wednesday afternoon it was not clear where Jordan or Meadows would land.

Meadows told reporters on Wednesday that he believes Jordan has "earned" the spot of ranking member on the Judiciary Committee.

"I think Jim has earned the position for ranking member on Judiciary, but that's not my call. That's going to be the Steering Committee's call, and certainly as we look at that they will be making those decisions after Thanksgiving," he said.

Politico first reported Wednesday that Trump has privately pushed McCarthy to make a deal with Jordan.

A separate source confirmed to CNN that Jordan is interested in the ranking member position on the Judiciary Committee in order to check Democratic investigations that will be led by Rep. Jerry Nadler of New York.

In his race for minority leader, McCarthy positioned himself as a close ally of Trump. In a letter announcing his bid , he wrote, "We need to lay the groundwork to regain the majority so that we can continue working alongside President Trump to fulfill our promise to fundamentally change Washington. I helped build a majority from a deeper hole than this and I have what it takes to do it again."

As minority leader, McCarthy will become the most visible face of opposition to the incoming Democratic majority. The next minority leader will have to decide whether and when the GOP minority might work to find common ground with Democrats and could also come under increased scrutiny from the President as the administration itself goes under a microscope in the new Democratic-controlled House.

The leadership election comes as incoming freshmen lawmakers are in town for orientation.

At Wednesday's news conference, McCarthy said he does not believe that the President is to blame for House Republicans losing their majority, but he conceded that the party has work to do to improve its standing with voters, particularly in suburban areas.

"History is against us," he said. "Any President in their first off-year election, on average, loses more than 30 seats."

But McCarthy added, "We took a beating inside the suburban areas. We're going to have to work harder. I think our message is going to have to be clearer. Our ideas are going to have to be stronger. We realize that, and we will work toward that effort."

This story has been updated.