WASHINGTON — President Trump failed repeatedly to get Congress to pass a new healthcare law. He came up empty on immigration and gun bills after giving lawmakers conflicting messages. His budgets were ignored on Capitol Hill. And after 17 months in office, he has yet to even write his long-promised measure to repair the nation’s infrastructure.

Yet when it comes to stocking the nation’s federal courts, Trump has performed with remarkable efficiency and success. He got the Senate to confirm conservative judge Neil M. Gorsuch for the Supreme Court soon after taking office and since has been remaking the lower courts far more quickly than his predecessors.

His secret: outsourcing.

Unlike in other areas in which Trump insists on calling the shots — going with his gut, impulsively tweeting and altogether dispensing with the sort of deliberate and disciplined strategy essential to working with Congress — the president has deferred to a trio of more experienced hands when it comes to the judicial nominations so important to his conservative base.

“This is a zone where Trump is willing to say, ‘I got a guy here who knows what he’s doing,’ ” said Newt Gingrich, the former House speaker and informal Trump advisor.

Gingrich was talking about Donald McGahn, the White House counsel who has held a tight grip on the interview process. Yet Gingrich and others give singular credit to Leonard Leo, the executive vice president of the Federalist Society, a national network of conservative lawyers; Leo, starting at Trump’s request during the 2016 campaign, worked along with the Heritage Foundation to create the unprecedented list of Supreme Court candidates that Trump has used to select Gorsuch and his soon-to-be-announced pick.

The third player is Senate Majority Leader Mitch McConnell (R-Ky.), a master tactician who for nearly a year blocked President Obama’s final Supreme Court pick, Merrick Garland, leaving the vacancy for Trump to fill, with Gorsuch. Since then McConnell has engineered smooth confirmations in the narrowly Republican-controlled Senate for Gorsuch and dozens of lower-court nominees, almost all of whom have been vetted by Leo. McConnell calls his role in the judiciary’s makeover his proudest legacy.

Lesser known than the other two men, Leo has spent decades working toward a judiciary that shares his antiabortion rights views and conservative positions on interpreting the Constitution narrowly. As he did during the Gorsuch confirmation process, Leo has taken a leave from the Federalist Society to advise Trump. This week he created a war room to spearhead the selection and confirmation process.

Having already culled the list of potential nominees, Leo is now focusing on rallying conservatives and libertarians around the eventual pick. Aware of Trump’s need for credit and praise, he has been careful to minimize his influence in public comments.

“At the end of the day presidents are Type A personalities,” Leo said in an interview. “They drive things that they want, and anybody who suggests otherwise is just not aware of what’s going on.”

Leo said Trump is looking for three qualities: a candidate with “a good resume and a good pedigree,” who interprets the Constitution as the framers intended and is not weak, the last a quality Trump emphasizes in all of his personnel decisions.

“You have to be someone who is courageous and is not going to bend to pressure,” Leo said. “When someone comes to Washington, there’s a lot of cultural and social pressure.”

The list Leo began preparing during the campaign now includes 25 people, all but one of them judges with long records on the issues conservatives most care about. Candidate Trump released it to assure conservative voters who were wary of him, a thrice-married man and former Democrat who had an inconsistent record on abortion, gun control and other litmus-test issues.

Trump has said that on Monday he will name a replacement for Justice Anthony M. Kennedy, who announced last week he would soon retire. Among the potential nominees is Sen. Mike Lee, a Republican from Utah who spoke by phone with Trump on Monday, according to a White House statement Tuesday.

White House Principal Deputy Press Secretary Raj Shah said Trump spoke to three other candidates Tuesday, whom Shah did not name. The president interviewed four appeals court judges at the White House on Monday, according to several reports: Amy Coney Barrett of the 7th Circuit, Brett Kavanaugh of the District of Columbia Circuit and Raymond Kethledge and Amul Thapar of the 6th Circuit.

“There are no surprises and there won’t be any surprises, regardless of who the president picks from that list,” said Amanda L. Hollis-Brusky, author of the book “Ideas With Consequences: The Federalist Society and the Conservative Counterrevolution.”

“They’re young. They’re known to the organization,” said Hollis-Brusky, a politics professor at Pomona College.

Hollis-Brusky noted that liberal and moderate attorneys can affiliate with any number of legal societies to gain the type of credential they need to win judgeships. Yet for conservatives, she said, the Federalist Society has consolidated power on the right in a matter of decades, giving the group unique control and knowledge of the right-leaning legal community.

“Their mantra really is ‘No more David Souters,’ ” she said, referring to the justice nominated by President George H.W. Bush who wound up being far more moderate than many Republicans expected when he joined the court in 1990.

Modern nominees rarely preview how they would rule on cases during Senate hearings. And Trump has said that — on his advisors’ recommendation — he is not asking nominees directly whether they would overrule Roe vs. Wade, the 1973 Supreme Court ruling that defined a constitutional right to abortion. With the list of previously vetted candidates, Trump does not need to.

“When you look at the candidates being talked about, they have pretty extensive ruling histories,” said a White House official who declined to be named discussing internal strategy. “So you kind of have an idea where they land on certain issues.”

Democrats and some legal experts are livid over the role Trump has given to Leo and the Federalist Society, seeing it as a break with traditions designed to reduce the role of politics in selecting a justice. The moderate Republicans whose support Trump needs, Sens. Susan Collins of Maine and Lisa Murkowski of Alaska, also have suggested that Trump should look beyond his list for more centrist nominees.

In another break from norms, during his campaign Trump was explicit that he would choose justices who would overturn Roe and strike down restrictions on firearms.

“Nobody would have even dared to even breathe anything close to something like that” before Trump, said a Senate Democratic aide who was not authorized to speak publicly.

Douglas W. Kmiec, who vetted judicial nominees in the Reagan administration, said Ronald Reagan would never have allowed the Federalist Society to vet his nominees, thinking it “a betrayal of the presidential process.”

“As a political gambit, it’s unassailable,” Kmiec said of Trump’s list, noting that it helped Trump gain political backing from evangelical voters and other conservative skeptics during the campaign.

But what’s objectionable, he said, is “just the precedent of a president giving up this authority en masse.”

noah.bierman@latimes.com

Twitter: @noahbierman