The F.B.I. director, Christopher Wray, has begun clearing the Augean stables at the Federal Bureau of Investigation, which should prompt a broader — and long overdue — cleanup of the government’s sloppy intelligence operations.

But he and Attorney General Jeff Sessions may face their greatest obstacle in the form of their president. Donald Trump’s impulse to transform every activity of government into a partisan conflict undermines the difficult task of repairing a Justice Department that sorely needs it.

On Monday, Mr. Wray’s reform effort took an important step forward with the resignation of Andrew McCabe, the F.B.I.’s deputy director. Mr. McCabe had worked on the F.B.I.’s investigation into Hillary Clinton’s unsecured private computer network even though his wife, as a candidate for a Virginia State Senate seat, had received $500,000 in campaign contributions from a Clinton friend.

That conflict of interest was one of many during the 2016 election that seemed to afflict Main Justice, as the Justice Department headquarters is known (and where I worked in the George W. Bush administration with Mr. Wray, whom I have known since law school). Attorney General Loretta Lynch’s tarmac meeting with former President Bill Clinton in June 2016, while his wife was under investigation, created another appearance of a conflict of interest. Ms. Lynch’s recusal led to the July news conference where James Comey announced that he would not seek charges against Hillary Clinton.