WASHINGTON — When President Trump tapped Christopher A. Wray to be his next F.B.I. director, it signaled a clear break from the tenure of James B. Comey, whom Mr. Trump had grown to distrust and eventually fired.
It seemed Mr. Trump would let his handpicked F.B.I. director do his work unimpeded, giving Mr. Wray some breathing room. “I know that he will again serve his country as a fierce guardian of the law and model of integrity,” the president said in June.
But nearly five months since Mr. Wray started the job, Mr. Trump has not made Mr. Wray’s life easier as he seeks to restore the public’s confidence in the country’s premier law enforcement agency — one that the president says is in “Tatters.”
Mr. Trump’s verbal assaults have put Mr. Wray and his leadership team in a difficult position. Mr. Wray is trying to move past his predecessor’s era and make sure there is not a whiff of politics at the F.B.I. He has promised the F.B.I.’s work would be based on the “facts, the law and the impartial pursuit of justice — period.”
Yet Mr. Trump and his allies in Congress are making that task much harder.
Current and former F.B.I. officials say Mr. Trump’s criticisms, and those of normally supportive Republican members of Congress, have damaged morale in some quarters of the bureau. Senior agents have expressed fear that if their names appear in the news media, they will be singled out for attack by politicians.
During a congressional hearing this month, Representative Louie Gohmert, Republican of Texas, asked Mr. Wray about the political views of some of his top agents. F.B.I. officials said they were stunned that Mr. Gohmert singled out a seemingly random group of agents. Several of those mentioned had nothing to do with either the investigation into Hillary Clinton’s handling of classified information, or the F.B.I.’s inquiry into Russian interference in the 2016 election.
When Mr. Wray accepted the offer to replace Mr. Comey, he knew the job would not be for the “faint of heart,” as he told Congress during his confirmation hearing. He has had to walk a fine line, trying to gently rebuff the president while not inviting a direct confrontation with him. Mr. Wray has kept a low profile, making sure his anodyne speeches inside and outside the F.B.I. do not inflame the White House.
“He’s got to be the top cover for the agency,” said James F. Yacone, a former senior F.B.I. official who retired in 2015. “He’s the chief fact collector, and he has to avoid being politicized. He has a difficult job.”
Shortly after it was revealed early this month that a senior F.B.I. agent and counterintelligence lawyer who worked on both the Clinton and Russia investigations had made anti-Trump comments while exchanging texts, the president said in a Twitter post that the F.B.I.’s “reputation is in Tatters.”
The White House press secretary, Sarah Huckabee Sanders, has sought to clarify Mr. Trump’s remarks. She said the president was “referring to the political leaders at the F.B.I., particularly those that were involved in the Hillary Clinton probe.”
In a statement, Raj Shah, a deputy White House press secretary, described Mr. Trump as having “enormous respect for the thousands of rank-and-file F.B.I. agents who make up the world’s most professional and talented law enforcement agency.”
Mr. Shah added: “He believes politically motivated senior leaders, including former Director Comey and others he empowered, have tainted the agency’s reputation for unbiased pursuit of justice. The president appointed Chris Wray because he is a man of true character and integrity, and the right choice to clean up the misconduct at the highest levels of the F.B.I. and give the rank and file confidence in their leadership.”
Officials said Mr. Wray cannot be seen inside the F.B.I. as dismantling the existing management team merely because the president does not approve of it — a move that would appear political and hurt the director’s standing among agents.
Many of Mr. Wray’s senior leadership team members were promoted under Mr. Comey, including Andrew G. McCabe, the embattled deputy director. Mr. Wray has to decide on the future of Mr. McCabe, who has been singled out by Mr. Trump because of his wife’s political activities and because of his role as deputy director during the Clinton email investigation.
In 2015, Mr. McCabe’s wife, Jill McCabe, ran as a Democrat for a Virginia State Senate seat and accepted nearly $500,000 in contributions from the political organization of Gov. Terry McAuliffe, a longtime friend of Mrs. Clinton and her husband, former President Bill Clinton.
Officials said that Mr. McCabe is seen inside the F.B.I. as a distraction for Mr. Wray — and a punching bag for Mr. Trump and Republicans who have tried to turn him into a prominent example of political bias at the bureau. In private conversations, Mr. Trump has groused that Mr. Wray has not swiftly removed people whom he perceives as loyal to Mr. Comey.
Even agents who believe that Mr. McCabe is being treated unfairly agree that, for Mr. Wray to succeed, he will most likely have to choose a new deputy.
Officials say that Mr. Wray is leaning toward promoting David L. Bowdich, currently the third ranking official in the bureau. He is well liked inside the F.B.I. and is seen as someone who was not part of Mr. McCabe’s inner circle. Mr. Bowdich, the former top agent in the Los Angeles Field Office, is best known for being the public face of the F.B.I. in California after the 2015 San Bernardino terrorist attack.
Other changes are already in the works. On a conference call on Wednesday, it was announced that James A. Baker, the F.B.I. general counsel who was seen as an ally of Mr. Comey’s, would step down from that post, although he will remain at the bureau. Mr. Baker provided counsel to Mr. Comey during the investigation into Mrs. Clinton’s emails.
Mr. Wray has so far avoided a public dispute with Mr. Trump, primarily leaving the job of defending the bureau to former F.B.I. officials. In the December hearing before the House Judiciary Committee, he did push back against some of the president’s comments, albeit in a nonconfrontational way.
If Mr. Trump continues to go after the F.B.I., however, Mr. Wray might have to change course and risk a blowup. F.B.I. agents want to know that the director has their back.
“The troops need to know and understand that he has their best interests in heart,” Mr. Yacone said. “I think he is doing this to the best of his abilities under the extraordinary circumstances.”