But the report — initiated in response to a chorus of requests from Congress and the public — was far from an exoneration. Mr. Horowitz was unsparing in his criticism of Mr. Comey and referred five F.B.I. employees for possible discipline over pro-Clinton or anti-Trump commentary in electronic messages. He said agents were far too cozy with journalists. And he described a breakdown in the chain of command, calling it “extraordinary” that the attorney general acceded to Mr. Comey during the most controversial moments of the Clinton investigation.

The result, Mr. Horowitz said, undermined public confidence in the F.B.I. and sowed doubt about the bureau’s handling of the Clinton investigation, which even two years later remains politically divisive. Mrs. Clinton’s supporters blame Mr. Comey for her election loss. Mr. Trump believes that Mr. Comey and his agents conspired to clear Mrs. Clinton of wrongdoing because they were openly hostile to his candidacy.

Mr. Horowitz repeatedly said he found no evidence that the F.B.I. rigged the outcome. “Our review did not find documentary or testimonial evidence directly connecting the political views these employees expressed in their text messages and instant messages to the specific investigative decisions we reviewed,” the report said.

The report is especially critical of two F.B.I. officials, Peter Strzok and Lisa Page, who exchanged texts disparaging Mr. Trump. Many of those text messages had already been released, but the report cites a previously undisclosed exchange:

Mr. Trump is “not ever going to become president, right? Right?!” Ms. Page wrote.

“No,” Mr. Strzok wrote. “No he won’t. We’ll stop it.”

Ms. Page has left the F.B.I. and Mr. Strzok has been reassigned to human resources. Like other top F.B.I. officials, they were involved in both the Clinton case and the investigation into the Trump campaign’s ties to Russia. So while the inspector general’s report focuses entirely on the Clinton case, it has ramifications for the investigation being carried out by the special counsel, Robert S. Mueller III. Any evidence of bias or rule-breaking in one case could be used to undermine confidence in the other.