As an experienced prosecutor, FBI Director James Comey knows that the government’s power to bring criminals to justice is as narrow as it is awesome. It can initiate proceedings that will put people in jail for decades, but only when it is ready and able to present evidence of guilt beyond a reasonable doubt sufficient to persuade a jury of one’s peers. Short of that, its job is to announce that no charges will be filed, and shut up. It is not the schoolmarm in chief, empowered to criticize the citizenry for perceived but uncharged digressions that fall short of chargeable crimes.

So how in July did Comey become a public commentator on the moral failings of Hillary Clinton’s e-mail practices, even as he maintained without quaver that no prosecutable case could be brought? And why on Friday, in the heat of the election contest, did he decide to share with the entire country — as he must have known would happen the minute the letter arrived on the Hill — the totally obscure message that material “pertinent to the investigation” had been located and would be reviewed? Indeed, what gave him the conviction to so proceed, even over the reported objections of his bosses, the attorney general and the deputy attorney general?

The explanation seems to be a story of hubris rooted in Comey’s admirable personal penchant for openness and transparency. After a wonderful, mostly government-lawyering career, in which he built an unassailable reputation for competence and integrity, he came to the main Justice Department as deputy attorney general in the George W. Bush administration. There, on March 10, 2004, he found himself with the challenge to perform in one of those incredible moments that history and movies are made of.

Along with others, notably his predecessor at the FBI, Robert Mueller III, and Jack Goldsmith, the head of the Justice Department’s Office of Legal Counsel, he raced to the George Washington Hospital to reach the bedside of the seriously ill Attorney General John Ashcroft, just in time to stop the president’s men, Alberto Gonzales and Andrew Card Jr., from securing Ashcroft’s reauthorization of Bush’s domestic surveillance program, which Justice had found to be unconstitutional. The effort was successful, the White House was rebuffed, and Comey’s reputation for courage and principle rightly blossomed.

Fast-forward to 2016. Comey, now at the helm of the FBI, is again invited to play a pivotal role in a matter of great national importance — to make the final call on whether to recommend prosecution of the Democratic candidate for president for mishandling her e-mails and maintaining a separate server. In a Sept. 7 letter to FBI employees, he explained his thinking about the July decision in his characteristically straightforward way. He said that there were two aspects of the decision — whether to recommend prosecution and how to talk with the public about that decision:

“At the end of the day, the case was not a cliffhanger; despite all the chest-beating by people no longer in government, there really wasn’t a prosecutable case,” he said. “The hard part was whether to offer unprecedented transparency about our thinking. I explain to our alumni that I struggled with that part, but decided … to announce it in the way we did — with extraordinary transparency and without any kind of coordination.”

Comey’s struggle with the issue of transparency was resolved incorrectly. That would be obvious in any ordinary criminal investigation, where evidence and the reasons for declining prosecution are never discussed. The answer doesn’t change when the investigation bears upon a candidate for public office — here the presidency. Actually, the idea that materials gathered in a governmental investigation resolved without prosecution should, in the name of transparency, be made known in summary form when relevant for the guidance of voters is quite frightening. For that reason and others, prudent Justice Department policy has long bent over backward to avoid actions in connection with investigations or cases that might affect pending elections.

Friday’s letter, providing notice of the discovery of documents that the FBI had not yet evaluated for significance, was a further exercise in full disclosure about the status of an investigation, and is likewise an inappropriate exercise of governmental power. Here, obviously, the interests of Clinton and her campaign are compromised by the public disclosure that the government has found some new documents of unknown content. Even more important, so are the interests of the country in conducting an election free from the foreseeable public confusion and potential electoral consequences, indeed here based on no substantive information at all.

The short of it is that Comey’s quest for transparency is quite out of place in the context of his role as the decisionmaker whether to recommend prosecution. The government’s job is to investigate, charge and prosecute, or announce that no charges will be brought. It has no business using the fruits of its investigation to provide commentary on the attributes of citizens, even if they are candidates for president. In failing to realize this, like many before him, Comey seems to have confused his sense of his stellar standing as a person and moral exemplar with the limits of his role as a public official.

Donald B. Ayer served as U.S. attorney for the Eastern District of California, principal deputy solicitor general and deputy attorney general under Presidents Reagan and George H.W. Bush. He wrote this article for the Washington Post.