Mr. McGahn has spent most of his professional career in Washington, unusual in an administration that has largely kept out Beltway insiders. His wife, Shannon McGahn, is the staff director of the House Financial Services Committee.

But over the years he developed an unusual image for a conservative, growing his hair long and playing guitar for a rock band that specialized in 1980s cover songs until he had to focus on working for Mr. Trump.

That background dovetails with a policy record that is more libertarian than classically conservative. His specialty is election law, and at the Patton Boggs law firm, he worked under Benjamin Ginsberg, a veteran Republican campaign lawyer, defending clients against Federal Election Commission investigations into coordination between Republican campaign committees and outside groups.

Later, President George W. Bush appointed Mr. McGahn to serve as a commissioner on the Federal Election Commission, where he developed a reputation for unabashedly trying to stop what he believed were its regulatory excesses. But others saw his actions as preventing any regulations on campaign spending. After leaving the agency, he and Mr. Ginsberg left Patton Boggs for another firm, Jones Day.

“His outlook has always been on the fecklessness of overregulation by big government,” Mr. Ginsberg said, adding that the two “would spend countless hours” talking about what they saw as the foolishness of Federal Election Commission actions to “regulate the unregulatable” — that is, political campaign speech.

Since last summer, Mr. McGahn has played little role in dealing with the Russia investigation because the White House brought in outside lawyers — first Marc E. Kasowitz, and now Ty Cobb — to handle it. But in his more conventional work, which has been overshadowed by the attention given the legal sparring with Mr. Mueller, he has had a major effect on public policy through his support of efforts to dismantle regulations and his role in the administration’s aggressive attempt to fill vacancies in the upper reaches of the federal judiciary with deeply conservative judges.

“Everyone thinks about him in terms of the president’s ethics and all of that, but quietly, he has really tried to move the needle on things that conservatives care about a lot, which is the courts and the administrative state,” said Reginald Brown, a former associate White House counsel in the Bush administration. “That’s not as sexy, but it is far more consequential.”