As Donald Trump raged in an Oval Office 2½ weeks ago filled with tense senior aides, he trained his eyes on one in particular: White House counsel Don McGahn.

During the Friday afternoon tirade, which would spill into a Saturday morning tweetstorm on wiretapping Trump Tower, the new president erupted over his attorney general’s decision to step out of a sensitive investigation on Russian contacts and tangled with his team over how to redo his troubled travel ban.

His angriest remarks were reserved for McGahn, who was tasked with making a complex legal case on both fronts to a president concerned about political optics.

But less than 24 hours after being on the receiving end of a Trump smackdown, McGahn was in Florida with his boss at an amiable work session and dinner. The new travel ban the president signed later in the month shows he took the lawyer’s advice to stop pursuing his appeal of the first one.

In a White House that prides itself on defying the system, McGahn often has the unenviable task of defining that system’s parameters. He’s an in-house guardrail for a president who likes to veer out of traditional bounds, and McGahn certainly doesn’t win all of his battles.

Yet for far longer than anyone in the White House outside of Trump’s family, McGahn has retained his status of trusted confidant and adviser to a man who isn’t interested in making the job easy.

“Don’s style is such that it avoids having him get sucked into the vortex,” said Leonard Leo, an adviser to the White House on the Supreme Court nomination process and judicial and legal appointments. “He’s not yapping in the president’s ear just for the sake of being close to power. So when they do talk, it’s more meaningful.”

McGahn — a 48-year-old election lawyer who ended his side-gig as a guitarist in an ’80s cover band to take on the all-consuming White House post — walked into an empty West Wing office on Jan. 20. He’s lived the past month and a half in dog years. In rapid fire, he’s fielded unprecedented ethics questions, suffered a bruising legal defeat on a signature policy and managed the hiring, and one firing, of prominent officials.

A single tweet can send him scrambling without warning, as 2½ weeks ago when the president accused former President Barack Obama of wire-tapping his phone at Trump Tower. McGahn and his team were dispatched to find out what, if any, options the president had to learn more about the situation, according to White House spokesman Sean Spicer, who disputed there was anything inappropriate about the inquiry.

“If you know Don and the team here, these are unbelievably talented lawyers,” Spicer said. “They are very skilled at knowing where the bounds are.”

McGahn declined to comment for this story.

In one of his few interviews, with a conservative TV station during the Republican National Convention last summer, he laughed when asked to preview what Trump would say in his speech that night: “I wouldn’t dare begin to guess what Mr. Trump is going to say.”

His boss’ unpredictability isn’t McGahn’s only challenge. Trump’s business ties raise a pile of legal and ethical quandaries for this White House.

McGahn has hired 26 senior lawyers for his Office of the White House Counsel, including a team of four to contend with the nonstop questions that dog a billionaire president who retains a financial interest in his global real estate and marketing empire.

He has sought advice and support from many of his predecessors, including Obama’s first chief White House counsel Bob Bauer and George H.W. Bush’s top attorney C. Boyden Gray.

“It was more of a commiseration,” Gray said of his conversation with McGahn. While the elder Bush had a successful private-sector career in which he pioneered offshore drilling, he had sold everything off by the time he went into politics, he said. “There weren’t the entanglements the Trump family has.”

As the campaign’s general counsel, McGahn was with Trump on June 16, 2015, the day he announced his bid for the Republican presidential nomination.

He was with him on the ground in every important primary state and again on Nov. 8, as the final results rolled in. Only Jared Kushner, the president’s son-in-law-turned adviser, has also traveled each step in Trump’s improbable rise.

That familiarity has made McGahn comfortable enough with Trump to push him without permanently damaging their relationship — even if a discussion becomes “heated” or “spirited,” as two administration officials described the Friday afternoon blowup. The officials spoke on condition of anonymity to discuss the private conversations.

It fell to McGahn to explain that it was up to no one but Attorney General Jeff Sessions to make the decision to recuse himself from any investigation into Trump campaign links to Russia — a move that Trump argued felt like an admission of defeat.

“It can be emotionally draining,” the adviser Leo said. “You don’t just have to answer complex legal questions, but you have to do so in a way that is accepted and embraced by your boss.”

Although Trump’s first travel ban was written with little legal vetting, McGahn took heat for it as courts blocked it. Some legal experts called the executive order sloppy. The federal appeals panel said it could not rely on McGahn’s after-the-fact written assurance that lawful permanent residents were exempt. The new ban expressly does not apply to that group.

McGahn also was in the middle of the ouster of Michael Flynn, Trump’s first national security adviser. According to the White House, he was the first to learn from the acting attorney general, Sally Yates, that Flynn had not been forthcoming about the nature of his contacts with the Russian ambassador to the U.S.

McGahn took the information to Trump that same day, although Flynn wasn’t fired until after details were made public.

McGahn, who friends say has both the humor and intensity to withstand pressure, is a former chairman of the Federal Election Commission, where he pushed to give political groups and candidates more flexibility in raising and spending money.

His wife, Shannon, recently joined the Treasury Department as a senior adviser, after serving as staff director for the House Financial Services Committee.