– As federal prosecutors in Manhattan gathered evidence late last year about President Donald Trump’s role in silencing women with hush payments during the 2016 campaign, Trump called Matthew Whitaker, his newly installed attorney general, with a question. He asked whether Geoffrey S. Berman, the U.S. attorney for the Southern District of New York and a Trump ally, could be put in charge of the widening investigation, according to several U.S. officials with direct knowledge of the call.

Whitaker, who had privately told associates that part of his role at the Justice Department was to “jump on a grenade” for the president, knew he could not put Berman in charge because Berman had already recused himself from the investigation. The president soon soured on Whitaker, as he often does with his aides, and complained about his inability to pull levers at the Justice Department that could make the president’s many legal problems go away.

Trying to install a perceived loyalist atop a widening inquiry is a familiar tactic for Trump, who has been struggling to beat back the investigations that have consumed his presidency. His efforts have exposed him to accusations of obstruction of justice as Robert Mueller, the special counsel, finishes his work investigating Russian interference in the 2016 election.

Trump’s public war on the inquiry has gone on long enough that it is no longer shocking. Trump rages almost daily to his 58 million Twitter followers that Mueller is on a “witch hunt” and has adopted the language of Mafia bosses by calling those who cooperate with the special counsel “rats.” His lawyer talks openly about a strategy to smear and discredit the special counsel investigation. The president’s allies in Congress and the conservative media warn of an insidious plot inside the Justice Department and the FBI to subvert a democratically elected president.

An examination by the New York Times reveals the extent of an even more sustained, more secretive assault by Trump on the machinery of federal law enforcement. Interviews with dozens of current and former government officials and others close to Trump, as well as a review of confidential White House documents, reveal numerous unreported episodes in a two-year drama.

White House lawyers wrote a confidential memo expressing concern about the president’s staff peddling misleading information in public about the firing of Michael Flynn, the Trump administration’s first national security adviser. Trump had private conversations with Republican lawmakers about a campaign to attack the Mueller investigation. And there was the episode when he asked his attorney general about putting Berman in charge of the Manhattan investigation.

Whitaker, who this month told a congressional committee that Trump had never pressured him over the various investigations, is now under scrutiny by House Democrats for possible perjury.

A Justice Department spokeswoman said Tuesday that the White House had not asked Whitaker to interfere in the investigations. “Under oath to the House Judiciary Committee, then Acting Attorney General Whitaker stated that ‘at no time has the White House asked for nor have I provided any promises or commitments concerning the special counsel’s investigation or any other investigation,'” said the spokeswoman, Kerri Kupec. “Mr. Whitaker stands by his testimony.”

The White House declined to comment for this article.

The story of Trump’s attempts to defang the investigations has been voluminously covered in the news media, to such a degree that many Americans have lost track of how unusual his behavior is. But fusing the strands reveals an extraordinary story of a president who has attacked the law enforcement apparatus of his own government like no other president in history, and who has turned the effort into an obsession. Trump has done it with the same tactics he once used in his business empire: demanding fierce loyalty from employees, applying pressure tactics to keep people in line, and protecting the brand — himself — at all costs.

It is a public relations strategy as much as a legal strategy — a campaign to create a narrative of a president hounded by his “deep state” foes. The new Democratic majority in the House, and the prospect of a wave of investigations on Capitol Hill this year, will test whether the strategy shores up Trump’s political support or puts his presidency in greater peril. The president has spent much of his time venting publicly about there being “no collusion” with Russia before the 2016 election, which has diverted attention from a growing body of evidence that he has tried to impede the various investigations.

Julie O’Sullivan, a criminal law professor at Georgetown University, said she believed there was ample public evidence that Trump had the “corrupt intent” to try to derail the Mueller investigation, the legal standard for an obstruction of justice case.

But this is far from a routine criminal investigation, she said, and Mueller will have to make judgments about the effect on the country of making a criminal case against the president. Democrats in the House have said they will wait for Mueller to finish his work before making a decision about whether the president’s behavior warrants impeachment.

In addition to the Mueller investigation, there are at least two other federal inquiries that touch the president and his advisers — the Manhattan investigation focused on the hush money payments made by Trump’s lawyer, Michael Cohen, and an inquiry examining the flow of foreign money to the Trump inaugural committee.

The president’s defenders counter that most of Trump’s actions under scrutiny fall under his authority as the head of the executive branch. They argue that the Constitution gives the president sweeping powers to hire and fire, to start and stop law enforcement proceedings, and to grant presidential pardons to friends and allies. A sitting American president cannot be indicted, according to current Justice Department policy.

Trump’s lawyers add this novel response: The president has been public about his disdain for the Mueller investigation and other federal inquiries, so he is hardly engaged in a conspiracy. He fired one FBI director and considered firing his replacement. He humiliated his first attorney general for being unable to “control” the Russia investigation and installed a replacement, Whitaker, who has told people he believed his job was to protect the president. But that, they say, is Donald Trump being Donald Trump.

In other words, the president’s brazen public behavior might be his best defense.

The First Crisis

The investigation into Russian interference in the 2016 election and whether the Trump campaign aided the effort presented the new White House with its first crisis after only 25 days. The president immediately tried to contain the damage.

It was Feb. 14, 2017, and Trump and his advisers were in the Oval Office debating how to explain the resignation of Flynn, the national security adviser, the previous night. Flynn, who had been a top campaign adviser to Trump, was under investigation by the FBI for his contacts with Russians and secret foreign lobbying efforts for Turkey.

The Justice Department had already raised questions that Flynn might be subject to blackmail by the Russians for misleading White House officials about the Russian contacts, and inside the White House there was a palpable fear that the Russia investigation could consume the early months of a new administration.

As the group in the Oval Office talked, one of Trump’s advisers mentioned in passing what Paul Ryan of Wisconsin, then the speaker of the House, had told reporters — that Trump had asked Flynn to resign.

It was unclear where Ryan had gotten that information, but Trump seized on Ryan’s words. “That sounds better,” the president said, according to people with knowledge of the discussions. Trump turned to the White House press secretary at the time, Sean Spicer, who was preparing to brief the news media.

“Say that,” Trump ordered.

But was that true, Spicer pressed.

“Say that I asked for his resignation,” Trump repeated.

The president appeared to have little concern about what he told the public about Flynn’s departure, and he quickly warmed to the new narrative. The episode was among the first of multiple ham-handed efforts by the president to carry out a dual strategy: publicly casting the Russia story as an overblown hoax and privately trying to contain the investigation’s reach.

“This Russia thing is all over now because I fired Flynn,” Trump said over lunch that day, according to a new book by Chris Christie, a former New Jersey governor and a longtime Trump ally.

Christie was taken aback. “This Russia thing is far from over,” Christie wrote that he told Trump, who responded: “What do you mean? Flynn met with the Russians. That was the problem. I fired Flynn. It’s over.”

Jared Kushner, the president's son-in-law and senior adviser, who was also at the lunch, chimed in, according to Christie's book: “That’s right, firing Flynn ends the whole Russia thing.”

As Trump was lunching with Christie, lawyers in the White House Counsel’s Office met with Spicer about what he should say from the White House podium about what was a sensitive national security investigation. But when Spicer’s briefing began, the lawyers started hearing numerous misstatements — some bigger than others — and ended up compiling them all in a memo.

The lawyers’ main concern was that Spicer overstated how exhaustively the White House had investigated Flynn and that he said, wrongly, that administration lawyers had concluded there were no legal issues surrounding Flynn’s conduct.

Spicer later told people he stuck to talking points that he was given by the counsel’s office, and that White House lawyers expressed concern only about how he had described the thoroughness of the internal inquiry into Flynn. The memo written by the lawyers said that Spicer was presented with a longer list of his misstatements. The White House never publicly corrected the record.

Later that day, Trump confronted the FBI director, James Comey, in the Oval Office. The president told him that Spicer had done a great job explaining how the White House had handled the firing. Then he asked Comey to end the FBI’s investigation into Flynn, and that Flynn was a good guy.

Comey responded, according to a memo he wrote at the time, that Flynn was indeed a good guy. But he said nothing about ending the FBI investigation.

By March, Trump was in a rage that his attorney general, Jeff Sessions, had recused himself from the Russia inquiry because investigators were looking into the campaign, of which Sessions had been a part. Trump was also growing increasingly frustrated with Comey, who refused to say publicly that the president was not under investigation.

Trump finally fired Comey in May. But the president and the White House gave conflicting accounts of their reasoning for the dismissal, which only served to exacerbate the president’s legal exposure.

A week after the firing, The New York Times disclosed that the president had asked Comey to end the Flynn investigation. The next day, the deputy attorney general, Rod J. Rosenstein, appointed Mueller, a Republican, as special counsel.

Instead of ending the Russia investigation by firing Comey, Trump had drastically raised the stakes.

Boiling Frustration

Mueller’s appointment fueled Trump’s anger and what became increasingly reckless behavior — triggering a string of actions over the summer of 2017 that could end up as building blocks in a case by Congress that the president engaged in a broad effort to thwart the investigation.

On Twitter and in news media interviews, Trump tried to pressure investigators and undermine the credibility of potential witnesses in the Mueller investigation.

He directed much of his venom at Sessions, who had recused himself in March from overseeing the Russia investigation because of contacts he had during the election with Russia’s ambassador to the United States.

The president humiliated Sessions at every turn, and stunned Washington when he said during an interview with The Times that he never would have named Sessions attorney general if he had known Sessions would step aside from the investigation.

Privately, he tried to remove Sessions — he said he wanted an attorney general who would protect him — but didn’t fire him, in part because White House aides dodged the president’s orders to demand his resignation. Trump even called his former campaign manager, Corey Lewandowski, over the Fourth of July weekend to ask him to pressure Sessions to resign. Lewandowski was noncommittal and never acted on the request.

One of Trump’s lawyers also reached out that summer to the lawyers for two of his former aides — Paul Manafort and Flynn — to discuss possible pardons. The discussions raised questions about whether the president was willing to offer pardons to influence their decisions about whether to plead guilty and cooperate in the Mueller investigation.

The president even tried to fire Mueller himself, a move that could have brought an end to the investigation. Just weeks after Mueller’s appointment, the president insisted that he ought to be fired because of perceived conflicts of interest. Trump’s White House counsel, Don McGahn, who would have been responsible for carrying out the order, refused and threatened to quit.

The president eventually backed off.

A New Strategy: Discrediting an Investigation

Sitting in the Delta Sky Lounge during a layover in Atlanta’s airport in July 2017, Rep. Matt Gaetz, a first-term Republican from the Florida Panhandle, decided it was time to attack. Gaetz, then 35, believed that the president’s allies in Congress needed a coordinated strategy to fight back against an investigation they viewed as deeply unfair and politically biased.

He called Rep. Jim Jordan, a conservative Republican from Ohio, and told him the party needed “to go play offense,” Gaetz recalled in an interview.

The two men believed that Republican leaders, who publicly praised the appointment of Mueller, had been beaten into a defensive crouch by the unending chaos and were leaving Democrats unchecked to “pistol whip” the president with constant accusations about his campaign and Russia.

So they began to investigate the investigators. Trump and his lawyers enthusiastically encouraged the strategy, which, according to some polls, convinced many Americans that the country’s law enforcement apparatus was determined to bring down the president.

Within days of their conversation, Gaetz and Jordan drafted a letter to Sessions and Rosenstein, the first call for the appointment of a second special counsel to essentially reinvestigate Hillary Clinton for her handling of her emails while secretary of state — the case had ended in the summer of 2016 — as well as the origins of the FBI’s investigation of Flynn and other Trump associates.

The letter itself, with the signatures of only 20 House Republicans, gained little traction at first. But an important shift was underway: At a time when Trump’s lawyers were urging him to cooperate with Mueller and tone down his Twitter feed, the president’s fiercest allies in Congress and the conservative media were busy trying to flip the script on the federal law enforcement agencies and officials who began the inquiry into Trump’s campaign.

Gaetz and Jordan began huddling with like-minded Republicans, sometimes including Rep. Mark Meadows, a press-savvy North Carolinian close to Trump, and Rep. Devin Nunes of California, the head of the House Intelligence Committee.

Nunes, the product of a dairy farming family in California’s Central Valley, had already emerged as one of Trump’s strongest allies in Congress. He worked closely with Flynn during the Trump transition after the 2016 election, and he had a history of battling the CIA and other intelligence agencies, which he sometimes accused of coloring their analysis for partisan reasons. In the spring of 2017, he sought to bolster Trump’s false claim that President Barack Obama had ordered an illegal wiretap on Trump Tower.

Using Congress’ oversight powers, the Republican lawmakers succeeded in doing what Trump could not realistically do on his own: force into the open some of the government’s most sensitive investigative files — including secret wiretaps and the existence of an FBI informant — which were part of the Russia inquiry.

House Republicans opened investigations into the FBI’s handling of the Clinton email case and a debunked Obama-era uranium deal indirectly linked to Clinton. The lawmakers got a big assist from the Justice Department, which gave them private texts recovered from two senior FBI officials who had been on the Russia case. The officials — Peter Strzok and Lisa Page — repeatedly criticized Trump in their texts, which were featured in a loop on Fox News and became a centerpiece of an evolving and powerful conservative narrative about a cabal inside the FBI and Justice Department to take down Trump.

The president cheered the lawmakers on Twitter, in interviews and in private, urging Gaetz on Air Force One in December 2017 and in subsequent phone callsto keep up the House Republicans’ oversight work. He was hoping for fair treatment from Mueller, Trump told Gaetz in one of the calls just after the congressman appeared on Fox News, but that did not preclude him from encouraging his allies’ scrutiny of the investigation.

Later, when Nunes produced a memo alleging the FBI had abused its authority in spying on a former Trump campaign associate, Carter Page, Trump called Nunes a “Great American hero.” (The FBI said it had “grave concerns” about the memo's accuracy.)

The president became an active participant in the effort to attack American law enforcement. He repeatedly leaned on administration officials on behalf of the lawmakers — urging Rosenstein and other law enforcement leaders to flout procedure and share sensitive materials about the open case with Congress. As president, Trump has ultimate authority over information that passes through the government, but his interventions were unusual.

By the spring of 2018, Nunes zeroed in on new targets. In one case, he threatened to hold Rosenstein in contempt of Congress or even try to impeach him if the documents he wanted were not turned over, including the file used to open the Russia case. In another, he pressed the Justice Department for sensitive information about a trusted FBI informant used in the Russia investigation, a Cambridge professor named Stefan Halper — even as intelligence officials said that the release of the information could damage relationships with important allies.

The president chimed in, accusing the FBI, without evidence, of planting a spy in his campaign. “SPYGATE could be one of the biggest political scandals in history!” Trump wrote, turning the term into a popular hashtag.

Most Senate Republicans tried to ignore the House tactics, and not all House Republicans who participated in the investigations agreed with the scorched-earth approach. Rep. Trey Gowdy, R-S.C., a former federal prosecutor who had led Republicans in the Benghazi investigation, felt that figures like Gaetz and, in some cases, Nunes, were hurting their own cause with a sloppy, overhyped campaign that damaged Congress’ credibility.

Former Rep. Thomas J. Rooney, a Republican who sat on the Intelligence Committee and retired last year, was similarly critical. “The efforts to tag Mueller as a witch hunt are a mistake,” he said in an interview. “The guy is an American hero. He is somebody who has always spouted the rule of law in what our country is about.”

But Gaetz makes no apologies.

“Do I think it’s right that our work in the Congress has aided in the president’s defense?” he asked, before answering his own question.

“Yeah, I think it is right.”

Ultimately, strategy was successful in softening the ground for a shift in the president’s legal strategy — away from relatively quiet cooperation with Mueller’s investigators and toward a targeted and relentless frontal attack on their credibility and impartiality.

President Opens a New Front

Last April, Trump hired Rudy Giuliani, his longtime friend and a famously combative former mayor of New York, as his personal lawyer and ubiquitous television attack dog. A new war had begun.

In jettisoning his previous legal team — which had counseled that Trump should cooperate with the investigation — the president decided to combine a legal strategy with a public-relations campaign in an aggressive effort to undermine the credibility of both Mueller and the Justice Department.

Mueller was unlikely to indict Trump, the president’s advisers believed, so the real danger to his presidency was impeachment — a political act that Congress would probably only carry out only with broad public support. If Mueller’s investigation could be discredited, then impeachment might be less likely.

Months of caustic presidential tweets and fiery television interviews by Giuliani unfolded. The former mayor accused Mueller, without evidence, of bias and ignoring facts to carry out an anti-Trump agenda. He called one of Mueller’s top prosecutors, Andrew Weissmann, a “complete scoundrel.”

Behind the scenes, Giuliani was getting help from a curious source: Kevin Downing, a lawyer for Paul Manafort, who had been the president’s 2016 campaign chairman. Manafort had agreed to cooperate with the special counsel after being convicted of financial crimes in an attempt to lessen a potentially lengthy prison sentence. Downing shared details about prosecutors’ lines of questioning, Giuliani admitted late last year.

It was a highly unusual arrangement — the lawyer for a cooperating witness providing valuable information to the president’s lawyer at a time when his client remained in the sights of the special counsel’s prosecutors. The arrangement angered Mueller’s investigators, who questioned what Manafort was trying to gain from the arrangement.

The attacks on the Mueller investigation appeared to have an effect. Last summer, polling showed a 14-point uptick in the percentage of Americans polled who disapproved of how Mueller was handling the inquiry. “Mueller is now slightly more distrusted than trusted, and Trump is a little ahead of the game,” Giuliani said during an interview in August.

“So I think we’ve done really well,” Giuliani added. “And my client’s happy.”

FBI raids Michael Cohen

But Giuliani and his client had a serious problem, which they were slow to comprehend.

In April the FBI raided the Manhattan office and residences of Cohen — the president’s lawyer and fixer — walking off with business records, emails and other documents dating back years. At first, Trump wasn’t concerned.

The president told advisers that Rosenstein assured him at the time that the Cohen investigation had nothing to do with him. In the president’s recounting, Rosenstein told him the inquiry in New York was about Cohen's business dealings, it did not involve the president and was not about Russia. Since then, Trump has asked his advisers if Rosenstein was deliberately misleading him to keep him calm.

Giuliani initially portrayed Cohen as “honest,” and Trump praised him publicly. But Cohen soon told prosecutors in New York how Trump had ordered him during the 2016 campaign to buy the silence of women who claimed they had sex with the president. In a separate bid for leniency, Cohen told Mueller’s prosecutors about Trump’s participation in negotiations during the height of the presidential campaign to build a Trump Tower in Moscow.

Trump was now battling twin investigations that seemed to be moving ever close to him. And Cohen, once the president’s fiercest defender, was becoming his chief tormentor.

In a court appearance in August, Cohen pleaded guilty and told a judge that Trump had ordered him to arrange the payments to the women, Stormy Daniels and Karen McDougal. Cohen's descriptions of the president’s actions made Trump, in effect, an unindicted co-conspirator and raised the prospect of the president being charged after he leaves office. Rep. Jerrold Nadler, D-N.Y., who in January became the chairman of the House Judiciary Committee, which has jurisdiction over the matter, said the implied offense was probably impeachable.

The president struck back, launching a volley of tweets that savaged Cohen and his family — insinuating that Cohen's father-in-law had engaged in unexamined criminal activity. He called Cohen a “rat.” The messages infuriated Democratic lawmakers, who claimed the president was trying to threaten and intimidate a witness ahead of testimony Cohen planned before Congress.

“He’s only been threatened by the truth,” the president responded.

Another Attorney General Takes Office

As the prosecutors closed in, Trump felt a more urgent need to gain control of the investigation.

He made the call to Whitaker to see if he could put Berman in charge of the New York investigation. The inquiry is run by Robert Khuzami, a career prosecutor who took over after Berman, whom Trump appointed, recused himself because of a routine conflict of interest.

What exactly Whitaker did after the call is unclear, but there is no evidence he took any direct steps to intervene in the Manhattan investigation. He did, however, tell some associates at the Justice Department that the prosecutors in New York required “adult supervision.”

Trump moved on to a new attorney general, William P. Barr, whom Trump nominated for the job in part because of a memo Barr wrote last summer making a case that a sitting American president cannot be charged with obstruction of justice for acts well within his power — like firing an FBI director.

A president cannot be found to have broken the law, Barr argued, if he was exercising his executive powers to fire subordinates or use his “complete authority to start or stop a law enforcement proceeding.”

The memo might have ingratiated Barr to his future boss, but Barr is also respected among the rank and file in the Justice Department. Many officials there hope he will try to change the Trump administration’s combative tone toward the department as well as toward the FBI.

Whether it is too late is another question. Trump’s language, and allegations of “deep state” excesses, are now embedded in the political conversation, used as a cudgel by the president’s supporters.

Last December, days before Flynn was to be sentenced for lying to the FBI, his lawyers wrote a memo to the judge suggesting that federal agents had tricked the former national security adviser into lying. The judge roundly rejected that argument, and on sentencing day he excoriated Flynn for his crimes.

The argument about FBI trickery did, however, appear to please the one man who holds great power over Flynn’s future — the constitutional power to pardon.

“Good luck today in court to General Michael Flynn,” Trump tweeted cheerily on the morning of the sentencing.