Over the next couple of days, Mr. Trump pestered Mr. McGahn about the firing, but Mr. McGahn would not tell Mr. Rosenstein. The badgering by the president got so bad that Mr. McGahn wrote a resignation letter and was prepared to quit. It was only after Mr. McGahn made it known to senior White House officials that he was going to resign that Mr. Trump backed down.

The articles that provoked Mr. Trump’s anger in December — which were published by Bloomberg, The Wall Street Journal and Reuters — said one of Mr. Mueller’s subpoenas had targeted Mr. Trump’s and his family’s banking records at Deutsche Bank. Mr. Trump’s lawyers, who have studied Mr. Trump’s bank accounts, did not believe the articles were accurate because Mr. Trump did not have his money there.

The lawyers were also able to learn that federal prosecutors in a different inquiry had issued a subpoena for entities connected to the family business of Mr. Trump’s son-in-law, Jared Kushner. The news outlets later clarified the articles, saying that the subpoena to Deutsche Bank pertained to people affiliated with Mr. Trump, who was satisfied with the explanation and dropped his push to fire Mr. Mueller.

The White House did not respond to an email seeking comment.

Acutely conscious of the threat Mr. Mueller’s investigation poses, Mr. Trump has openly discussed ways to shut it down. Each time, he has been convinced by his lawyers and advisers that taking the step would only exacerbate his problems. In some cases, they have explained to Mr. Trump how anything that causes him to lose support from congressional Republicans could further imperil his presidency.

But Mr. Trump’s statements to his advisers have been significant enough to attract attention from Mr. Mueller himself. Mr. Mueller’s investigators have interviewed current and former White House officials and have requested documents to understand whether these efforts show evidence the president is trying to obstruct the Justice Department’s investigation, according to two people briefed on the matter.

Mr. Trump’s frustrations have tended to flare up in response to developments in the news, especially accounts of appearances of witnesses, whom Mr. Trump feels were unfairly and aggressively approached by investigators. They include his former communications director, Hope Hicks, and his former campaign manager, Corey Lewandowski.

The venting has usually been dismissed by his advisers, many of whom insist they have come to see the statements less as direct orders than as simply how the president talks, and that he often does not follow up on his outbursts.

One former adviser said that people had become conditioned to wait until Mr. Trump had raised an issue at least three times before acting on it. The president’s diatribes about Attorney General Jeff Sessions, Mr. Rosenstein and the existence of the special counsel have, for most of the White House aides, become a dependable part of the fabric of life working for this president.