The facts, had they surfaced, might have devastated the Trump campaign: Mr. Trump’s future national security adviser was under investigation, as was his campaign chairman. One adviser appeared to have Russian intelligence contacts. Another was suspected of being a Russian agent himself.

In the Clinton case, Mr. Comey has said he erred on the side of transparency. But in the face of questions from Congress about the Trump campaign, the F.B.I. declined to tip its hand. And when The New York Times tried to assess the state of the investigation in October 2016, law enforcement officials cautioned against drawing any conclusions, resulting in a story that significantly played down the case.

Mr. Comey has said it is unfair to compare the Clinton case, which was winding down in the summer of 2016, with the Russia case, which was in its earliest stages. He said he did not make political considerations about who would benefit from each decision.

But underpinning both cases was one political calculation: that Mrs. Clinton would win and Mr. Trump would lose. Agents feared being seen as withholding information or going too easy on her. And they worried that any overt actions against Mr. Trump’s campaign would only reinforce his claims that the election was being rigged against him.

The F.B.I. now faces those very criticisms and more. Mr. Trump says he is the victim of a politicized F.B.I. He says senior agents tried to rig the election by declining to prosecute Mrs. Clinton, then drummed up the Russia investigation to undermine his presidency. He has declared that a deeply rooted cabal — including his own appointees — is working against him.

That argument is the heart of Mr. Trump’s grievances with the federal investigation. In the face of bipartisan support for the special counsel, Robert S. Mueller III, Mr. Trump and his allies have made a priority of questioning how the investigation was conducted in late 2016 and trying to discredit it.

“It’s a witch hunt,” Mr. Trump said last month on Fox News. “And they know that, and I’ve been able to message it.”