In early December, President Trump, furious over news reports about a new round of subpoenas from the office of the special counsel, Robert S. Mueller III, told advisers in no uncertain terms that Mr. Mueller’s investigation had to be shut down.

The president’s anger was fueled by reports that the subpoenas were for obtaining information about his business dealings with Deutsche Bank, according to interviews with eight White House officials, people close to the president and others familiar with the episode. To Mr. Trump, the subpoenas suggested that Mr. Mueller had expanded the investigation in a way that crossed the “red line” he had set last year in an interview with The New York Times.

In the hours that followed Mr. Trump’s initial anger over the Deutsche Bank reports, his lawyers and advisers worked quickly to learn about the subpoenas, and ultimately were told by Mr. Mueller’s office that the reports were not accurate, leading the president to back down.

Mr. Trump’s quick conclusion that the erroneous news reports warranted firing Mr. Mueller is also an insight into Mr. Trump’s state of mind about the special counsel. Despite assurances from leading Republicans like Speaker Paul D. Ryan that the president has not thought about firing Mr. Mueller, the December episode was the second time Mr. Trump is now known to have considered taking that step. The other instance was in June, when the White House counsel, Donald F. McGahn II, threatened to quit unless Mr. Trump stopped trying to get him to fire Mr. Mueller.

The December episode, which has never been publicly reported, has new resonance following the disclosure on Monday that F.B.I. agents had carried out search warrants at the office and hotel room of Mr. Trump’s personal lawyer, Michael D. Cohen. In that action, the Justice Department seems to have walked directly up to — if not crossed — Mr. Trump’s red line by examining something that seems unrelated to Russia.

Among the documents the agents sought were some related to two women who said they had affairs with Mr. Trump, and information related to the role of the publisher of The National Enquirer in silencing one of the women.

After learning about the raid, the president again erupted in anger. He told reporters that federal authorities had “broke in to the office” and he called it “a disgraceful situation” and “a total witch hunt.”

When Mr. Trump told Mr. McGahn in June to have Mr. Mueller fired, the president cited a series of conflict-of-interest issues that he insisted disqualified the special counsel from overseeing the investigation. Among the issues Mr. Trump cited was a dispute Mr. Mueller had with Mr. Trump’s Washington-area golf course years earlier. Mr. Trump told Mr. McGahn to tell Rod J. Rosenstein, the deputy attorney general and Mr. Mueller’s superior, that the time for Mr. Mueller to go had come.

Mr. McGahn believed those issues were not grounds for Mr. Mueller to be fired and refused to call the Justice Department.

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.

A version of this article appears in print on , on Page A18 of the New York edition with the headline: Trump, Angry About Reports of Subpoenas, Nearly Fired Mueller in December. Order Reprints | Today’s Paper | Subscribe