WASHINGTON — The day after President Donald Trump asked James B. Comey, the FBI director, to end an investigation into his former national security adviser, Comey confronted Attorney General Jeff Sessions and said he did not want to be left alone again with the president, according to current and former law enforcement officials.

Comey believed Sessions should protect the FBI from White House influence, the officials said, and pulled him aside after a meeting in February to tell him that private interactions between the FBI director and the president were inappropriate. But Sessions could not guarantee that the president would not try to talk to Comey alone again, the officials said.

Comey did not reveal, however, what had so unnerved him about his Oval Office meeting with the president: Trump's request that the FBI director end the investigation into the former national security adviser, Michael T. Flynn, who had just been fired. By the time Trump fired Comey last month, Comey had disclosed the meeting to a few of his closest advisers but nobody at the Justice Department, according to the officials, who did not want to be identified discussing Comey's interactions with Trump and Sessions.

Comey will be the center of attention on Thursday during testimony before the Senate Intelligence Committee, where he is expected to be quizzed intensely about his interactions with Trump and why he decided to keep secret the president's request to end the Flynn investigation.

Comey's unwillingness to be alone with the president reflected how deeply Comey distrusted Trump, who Comey believed was trying to undermine the FBI's independence as it conducted a highly sensitive investigation into links between Trump's associates and Russia, the officials said. By comparison, Comey met alone at least twice with President Barack Obama.

A spokesman for the FBI declined to comment on Comey's request. A Justice Department spokesman, Ian Prior, said that "the attorney general doesn't believe it's appropriate to respond to media inquiries on matters that may be related to ongoing investigations."

The Justice Department typically walls off the White House from criminal investigations to avoid even the appearance of political meddling in law enforcement. But Trump has repeatedly interjected himself in law enforcement matters, and never more dramatically than in his private meetings with Comey.

"You have the president of the United States talking to the director of the FBI, not just about any criminal investigation, but one involving his presidential campaign," said Matthew S. Axelrod, who served in senior Justice Department roles during the Obama administration and is now a partner at the law firm Linklaters. "That is such a sharp departure from all the past traditions and rules of the road."

But that raises one of the questions Comey will have to answer in his testimony on Thursday. If he believed that Trump was trying to get him to end an investigation, why did he not tell anyone about it?

Trump's defenders note that Andrew G. McCabe, the acting director of the FBI, has said that "there has been no effort to impede our investigation." Current and former law enforcement officials say Comey kept his interactions with Trump a secret in part because he was not sure whom at the Justice Department he could trust.

FBI officials were also unsure whether what Trump had done was a crime or how the conversation could ever be corroborated. So Comey kept the circle of officials at the FBI who knew about his interactions with Trump small because he did not want agents and analysts working on the case to be influenced by what the president wanted.

Comey's decision to keep his interactions with Trump a secret from the Justice Department were the latest example of how he set himself apart from the department throughout his tenure at FBI director.

Several times during the FBI's investigation into Hillary Clinton's personal email server last year, for example, Comey made decisions without the Justice Department's knowledge or approval, often to the consternation of Loretta Lynch, then the attorney general. Comey has said he made those decisions to protect the independence of the FBI — decisions that have been praised and criticized along partisan lines.

"In a legal sense, we're not independent of the Department of Justice," Comey told Congress last month. "We are spiritually, culturally pretty independent group, and that's the way you would want it."

Comey is also likely to be asked Thursday what he told Trump about the Russia investigation. Trump has told aides and said publicly that, on three occasions, Comey assured him that he was not under investigation.

Current and former law enforcement officials said that when the investigation was handed over last month to a special counsel, Robert S. Mueller III, Trump was not a target. But it is not clear what, if anything, Comey told the president about whether he was being investigated.

While Justice Department policy allows authorities to tell people whether they are the target of an investigation, prosecutors — not FBI agents — handle such discussions. "We typically do not answer that question," McCabe testified recently.

Former officials say Comey anticipated that the president might ask whether he was being investigated, and consulted his advisers on how to delicately sidestep the question. The officials were not aware of how Comey decided to answer.

When the Justice Department transferred the Russia investigation to Mueller, it gave him the authority to investigate whether the president broke any laws by attempting to obstruct the case or by firing Comey.

As FBI director, Comey wrote a detailed memo after every major phone call or meeting with Trump and left those memos in the bureau's files when he left. As special counsel, Mueller has access to those memos, but the FBI declined a request from the Senate Intelligence Committee for copies of the memos, citing the ongoing investigation. It is unclear whether Comey still has copies of all of them or plans to read from them during his testimony.

According to people briefed on the memos, they describe not only what Trump said, but details such as his tone and where he was sitting. In one memo, Comey described a dinner with Trump at the White House a week after the inauguration in January. Trump asked Comey to pledge his loyalty but Comey refused.

Two weeks later, on Feb. 14, Trump kicked Vice President Mike Pence, Sessions and other senior administration officials out of the Oval Office so he could have his one-on-one conversation with Comey, according to people briefed on one of Comey's memos.

It was in that conversation that Trump asked Comey to end the investigation into Flynn, and encouraged him to investigate leaks, the people said.

"I hope you can see your way clear to letting this go, to letting Flynn go," Trump told Comey, according to the memo Comey wrote describing that meeting. "He is a good guy. I hope you can let this go."

Asked Tuesday about Comey's coming testimony, Trump replied, "I wish him luck."

—