WASHINGTON — President Donald Trump gave firm instructions in March to the White House's top lawyer: stop the attorney general, Jeff Sessions, from recusing himself in the Justice Department's investigation into whether Trump's associates had helped a Russian campaign to disrupt the 2016 election.

Public pressure was building for Sessions, who had been a senior member of the Trump campaign, to step aside. But the White House counsel, Donald F. McGahn II, carried out the president's orders and lobbied Sessions to remain in charge of the inquiry, according to two people with knowledge of the episode.

McGahn was unsuccessful, and the president erupted in anger in front of numerous White House officials, saying he needed his attorney general to protect him. Trump said he had expected his top law enforcement official to safeguard him the way he believed Robert F. Kennedy, as attorney general, had done for his brother John F. Kennedy and Eric H. Holder Jr. had for Barack Obama.

Trump then asked, "Where's my Roy Cohn?" He was referring to his former personal lawyer and fixer, who had been Sen. Joseph R. McCarthy's top aide during the investigations into communist activity in the 1950s and died in 1986.

The lobbying of Sessions is one of several previously unreported episodes that the special counsel, Robert S. Mueller III, has learned about as he investigates whether Trump obstructed the FBI's Russia inquiry. The events occurred during a two-month period — from when Sessions recused himself in March until the appointment of Mueller in May — when Trump believed he was losing control over the investigation.

Among the other episodes, Trump described the Russia investigation as "fabricated and politically motivated" in a letter that he intended to send to the FBI director at the time, James B. Comey, but that White House aides stopped him from sending. Mueller has also substantiated claims that Comey made in a series of memos describing troubling interactions with the president before he was fired in May.

The special counsel has received handwritten notes from Trump's former chief of staff, Reince Priebus, showing that Trump talked to Priebus about how he had called Comey to urge him to say publicly that he was not under investigation. The president's determination to fire Comey even led one White House lawyer to take the extraordinary step of misleading Trump about whether he had the authority to remove him.

The New York Times has also learned that four days before Comey was fired, one of Sessions' aides asked a congressional staff member whether he had damaging information about Comey, part of an apparent effort to undermine the FBI director. It was not clear whether Mueller's investigators knew about this incident.

Mueller has also been examining a false statement that the president dictated on Air Force One in July in response to an article in The Times about a meeting that Trump campaign officials had with Russians during the campaign. A new book, "Fire and Fury: Inside the Trump White House," by Michael Wolff, says the president's lawyers believed that the statement was "an explicit attempt to throw sand into the investigation's gears," and that it led one of Trump's spokesmen to quit because he believed it constituted obstruction of justice.

Ty Cobb, the White House lawyer dealing with the special counsel's investigation, declined to comment.

Trump's lawyers have said the president has fully cooperated with the investigation, and they have expressed confidence that the inquiry will soon be coming to a close. They said that they believed the president would be exonerated, and that they hoped to have that conclusion made public.

Legal experts said that of the two primary issues Mueller appears to be investigating — whether Trump obstructed justice while in office and whether there was collusion between the Trump campaign and Russia — there is a larger body of public evidence tying the president to a possible crime of obstruction.

But the experts are divided about whether the accumulated evidence is enough for Mueller to bring an obstruction case. They said it could be difficult to prove that the president, who has broad authority over the executive branch, including the hiring and firing of officials, had corrupt intentions when he took actions like ousting the FBI director. Some experts said the case would be stronger if there was evidence that the president had told witnesses to lie under oath.

The accounts of the episodes are based on documents reviewed by The Times, as well as interviews with White House officials and others briefed on the investigation. They spoke on the condition of anonymity because they did not want to be identified discussing a continuing investigation.

Regardless of whether Mueller believes there is enough evidence to make a case against the president, Trump's belief that his attorney general should protect him provides an important window into how he governs. Presidents have had close relationships with their attorneys general, but Trump's obsession with loyalty is particularly unusual, especially given the Justice Department's investigation into him and his associates.

A Lawyer's Gambit

In late February, Sessions decided to take the advice of career Justice Department lawyers and recuse himself from the Russia investigation.

The pressure to make that decision public grew days later when The Washington Post reported that Sessions had met during the presidential campaign with Russia's ambassador to the United States. The disclosure raised questions about whether Sessions had misled Congress weeks earlier during his confirmation hearing, when he told lawmakers he had not met with Russians during the campaign.

Unaware that Sessions had decided to step aside from the inquiry, Democrats began calling for Sessions to recuse himself — and Trump told McGahn to begin a lobbying campaign to stop him.

McGahn's argument to Sessions that day was twofold: that he did not need to step aside from the inquiry until it was further along, and that recusing himself would not stop Democrats from saying he had lied. After Sessions told McGahn that career Justice Department officials had said he should step aside, McGahn said he understood and backed down.

Trump's frustrations with the inquiry erupted again about three weeks later, when Comey said publicly for the first time that the Justice Department and the FBI were conducting an investigation into links between Trump's campaign and Russia. Comey had told Trump in private that he was not personally under investigation, yet Comey infuriated Trump by refusing to answer a question about that at the hearing where he spoke publicly.

After that hearing, Trump began to discuss openly with White House officials his desire to fire Comey. This unnerved some inside the White House counsel's office, and even led one of McGahn's deputies to mislead the president about his authority to fire the FBI director.

The lawyer, Uttam Dhillon, was convinced that if Comey were fired, the Trump presidency could be imperiled, because it would force the Justice Department to open an investigation into whether Trump was trying to derail the Russia investigation.

Long-standing analysis of presidential power says that the president, as the head of the executive branch, does not need grounds to fire the FBI director. Dhillon, a veteran Justice Department lawyer before joining the Trump White House, assigned a junior lawyer to examine this issue. That lawyer determined that the FBI director was no different from any other employee in the executive branch, and that there was nothing prohibiting the president from firing him.

But Dhillon, who had earlier told Trump that he needed cause to fire Comey, never corrected the record, withholding the conclusions of his research.

Stephen I. Vladeck, a law professor at the University of Texas School of Law, called the incident "extraordinary," adding that he could not think of a similar one that occurred in past administrations.

"This shows that the president's lawyers don't trust giving him all the facts because they fear he will make a decision that is not best suited for him," Vladeck said.

Searching for Dirt

The attempts to stop Trump from firing Comey were successful until May 3, when the FBI director once again testified on Capitol Hill. He spent much of the time describing a series of decisions he had made during the bureau's investigation into Hillary Clinton's personal email account.

Once again, Comey refused to answer questions from lawmakers about whether Trump was under investigation.

White House aides gave updates to Trump throughout, informing him of Comey's refusal to publicly clear him. Trump unloaded on Sessions, who was at the White House that day. He criticized him for recusing himself from the Russia investigation, questioned his loyalty, and said he wanted to get rid of Comey. He repeated the refrain that the attorneys general for Kennedy and Obama had protected the White House.

In an interview with The Times last month, Trump said he believed Holder had protected Obama.

"When you look at the IRS scandal, when you look at the guns for whatever, when you look at all of the tremendous, aah, real problems they had, not made-up problems like Russian collusion, these were real problems," Trump said. "When you look at the things that they did, and Holder protected the president. And I have great respect for that, I'll be honest."

Two days after Comey's testimony, an aide to Sessions approached a Capitol Hill staff member asking whether the staffer had any derogatory information about the FBI director. The attorney general wanted one negative article a day in the news media about Comey, according to a person with knowledge of the meeting.

A Justice Department spokeswoman said the incident did not occur. "This did not happen and would not happen," said the spokeswoman, Sarah Isgur Flores. "Plain and simple."

Earlier that day, Rod J. Rosenstein, the deputy attorney general, had pulled one of McGahn's deputies aside after a meeting at the Justice Department. Rosenstein told the aide that top White House and Justice Department lawyers needed to discuss Comey's future. It is unclear whether this conversation was related to the effort to dig up dirt on Comey.

Trump spent the next weekend at his country club in Bedminster, New Jersey, where he watched a recording of Comey's testimony, stewed about the FBI director and discussed the possibility of dismissing him with his son-in-law, Jared Kushner, and his senior policy adviser, Stephen Miller. He had decided he would fire Comey, and asked Miller to help put together a letter the president intended to send to Comey.

In interviews with The Times, White House officials have said the letter contained no references to Russia or the FBI's investigation. According to two people who have read it, however, the letter's first sentence said the Russia investigation had been "fabricated and politically motivated."

On Monday, May 8, Trump met with Sessions and Rosenstein to discuss firing Comey, and Rosenstein agreed to write his own memo outlining why Comey should be fired. Before writing it, he took a copy of the letter that Trump and Miller had drafted during the weekend in Bedminster.

The president fired Comey the following day.

A week later, The Times reported that Trump had asked Comey in February to shut down the federal investigation into Michael T. Flynn, who at the time was the national security adviser. The following day, Rosenstein announced that he had appointed Mueller as special counsel.

Once again, Trump erupted at Sessions upon hearing the news. In an Oval Office meeting, the president said the attorney general had been disloyal for recusing himself from the Russia investigation, and he told Sessions to resign.

Sessions sent his resignation letter to the president the following day. But Trump rejected it, sending it back with a handwritten note at the top.

"Not accepted," the note said.