On Sunday, less than 48 hours before polls were due to open, FBI director James Comey took on a new role: Director of Damage Control.

Just nine days earlier, he told the world that he was effectively reviving an investigation that, according to longstanding prosecutorial rules, should have remained confidential. He also sought to reassert control over a bureau whose investigative leaks were hijacking a presidential election.

His letter to Congress Sunday, which announced that he had decided to stand pat with his original decision of last July and not seek charges against Hillary Clinton relating to her private email server and handling of classified information while secretary of state, popped a dirigible-sized balloon of innuendo, speculation, and false reporting that had unquestionably shifted the momentum of the entire race. FBI agents working round the clock, he noted, had finished reviewing “all the [newly found] communications that were to or from Hillary Clinton while she was secretary of state” and had, basically, found nothing new. (According to the Washington Post, the Clinton emails found were all either personal or duplicates of those previously examined.)

On one level, it was a confession of massive error on Comey’s part. His first letter to Congress, which came just eleven days before an election, irremediably altered the course and momentum of the race. It breathed new hope and funds into Donald Trump’s flagging campaign, propagated Clinton fatigue, and may have helped change the outcome of six battleground states. (It also roiled global financial markets. Fortune editor Alan Murray writes today that “stock markets around the world are rallying. . .ending an unusual nine-day losing streak.”)

Now Comey is pulling a Gilda Radner.

giphy

 

On the other hand, he desperately owed this admission to the electorate. Although it hadn’t been his intention, his letter of Oct. 28 had misled much of the nation (I was certainly among them) into assuming that there must be something more damning about the newly discovered trove of emails than Comey had let on in his understated letter. Otherwise how could he have possibly gone public with it?

As if that misimpression weren’t enough, Clinton’s opponent, Donald Trump, then inflated the damage to the limits of the imagination.

Although Comey had carefully acknowledged in his first letter that the FBI could “not yet assess whether or not this material may be significant,” Trump trumpeted a scandal “bigger than Watergate” and declared his opponent’s “corruption” to be “on a scale we have never seen before.”

By Saturday he was not only prognosticating imminent twin indictments for Hillary—one for mishandling classified information and another for purported Clinton Foundation pay-to-play improprieties—but making these new calumnies the centerpiece, if not the sum and substance, of his stump speeches.

“There’s little doubt that director Comey and the great special agents of the FBI will be able to collect more than enough evidence to garner indictments against Hillary Clinton and her inner circle,” he told a Sioux City, Iowa, crowd on Sunday a few hours before Comey’s latest letter was published, “despite her effort to disparage and discredit the FBI.”

After Comey’s letter emerged, stating that the latest emails contained nothing new, Trump campaign manager Kellyanne Conway told the New York Times, that Comey’s “investigation was mishandled from the beginning.” At the same time, Trump ally Newt Gingrich tweeted that Comey must have “caved” to “political pressure.”

(Trump’s own reactions have been muted. His handlers have finally staged an intervention, according to the Times, severely limiting his access to Twitter.)

Meanwhile, RNC chairman Reince Priebus stressed the allegation that “the FBI continues to investigate the Clinton Foundation for corruption.” He was alluding to one of many FBI investigations or preliminary inquiries alleged in media accounts to be taking place in recent weeks—some said to involve the Trump camp as well—which presumably arose from FBI or law enforcement sources.

In fact, these uncontrollable law enforcement leaks—by agents who might be either pro-Trump, anti-Clinton, or simply overzealous in their belief in their own inquiries and instincts—appear to be what drove Comey to breach longstanding Justice Department guidelines by going public in the first place.

Comey’s decision to notify Congress that an unrelated investigation had stumbled across a new cache of pertinent emails in a laptop owned by disgraced former Congressmen Anthony Weiner (D-NY)—the husband of longtime Hillary Clinton adviser Huma Abedin—appears to have been triggered by his fear that the existence of the new evidence was certain to leak out anyway.

If it had, the news would have certainly tarnished Comey’s reputation with Congress. Comey had unwisely promised to keep legislators updated about his inquiry. But it might have had as sensational an impact on the campaign as Comey’s letter of Oct. 28 ended up having.

Maybe worse, in fact.

If the information had come out via a leak from FBI agents, rather than from Comey’s official letter to Congress, it would have looked like Comey was part of a politically motivated effort to deep-six a new bombshell in the investigation.

So the core challenge for the nation, going forward, is not to find a way to teach FBI directors to keep their mouths shut. The challenge is to find a way to keep FBI agents’ mouths shut when, whether because of political bias or investigative zeal, they decide to take matters into their own hands and single-handedly influence a presidential election. I don’t have a solution for that problem, and neither did Comey.

In the Clinton camp, no one appears to be rejoicing at Comey’s latest letter. It certainly doesn’t place them back where they were nine days ago. Damage has been done that can’t be undone, and millions of people voted between Comey’s first letter and his second.

Nevertheless, thanks to that second letter, and to what must have been Herculean efforts by the agents working for him, it’s clear that Comey has now done all that was humanly possible to prevent innuendo from determining the outcome of this election.

Some Trump partisans may complain that his announcement, just two days before an election, is itself unfair. But that’s a truly pathetic argument. Comey is only disabusing the electorate of misimpressions left by his own unfortunate original mistake and of wildly false and malevolent speculations that the Trump camp never had any business spreading in the first place.

Comey owed the electorate this much and, this time, made the right call.