Vincent C. Gray was mayor of the District of Columbia from 2011 to 2015, chairman of the D.C. Council from 2007 to 2011 and Ward 7 councilmember from 2005 to 2007. He is the 2016 Democratic nominee for the Ward 7 D.C. Council seat.

Former mayor Vincent C. Gray in downtown Washington. (Evelyn Hockstein for The Washington Post)

Anyone who has ever been a candidate will tell you that politics is a rough-and-tumble business. Cheap shots, low blows and worse are to be expected. Good campaigns prepare responses and deflections. What campaigns do not prepare for, however, are sudden broadsides from law enforcement.

That’s what happened to Hillary Clinton in recent days. The same thing happened to me, too.

In March 2014, one week before the beginning of early voting in the District’s Democratic primary, then-U.S. Attorney Ronald Machen dropped a bombshell on my mayoral reelection campaign. He brought the kingpin of a political crime operation into court, announced that he’d struck a plea deal — and at a news conference thereafter, suggested that I was a co-conspirator and would soon be indicted.

The press and my primary opponent pounced. The circuslike atmosphere that followed dominated every news cycle until the polls closed April 1. Muriel Bowser had beaten me for the nomination.

Before what became known in District politics as “Machen Monday,” my campaign substantially led every public poll and our internal polls, as well. That lead, however, quickly evaporated, and there was no time to recover.

A year and a half later, long after the November general election, the U.S. attorney’s office ended the case. No charges were filed against me, nor was an iota of wrongdoing proved. Machen is back in private practice.

The case was much ado about nothing, but my reelection was sabotaged, and District voters were duped.

On Oct. 30, 11 days before Election Day and at a time when millions of Americans were already voting, FBI Director James Comey sprung a similar surprise on Clinton’s campaign, disclosing to Congress that the bureau had found a new batch of emails that could be pertinent to its investigation into her private server. News outlets and her opponent have focused on little else since. The damage to Clinton is yet to be determined.

The Justice Department has standards that direct prosecutors and law enforcement officials to avoid the appearance of meddling in elections. In my case and Clinton’s as well, these directives were disregarded.

Nothing is more important to candidates than the trust they build with voters. And nothing is more fragile. Law enforcement has an unrivaled ability to shatter that trust. Accordingly, it should not behave like a bull in a china shop.

When I heard what prosecutors were alleging about me, I was dumbfounded. After dedicating my entire career to uplifting people and making government work better for them, I found myself portrayed as someone I didn’t recognize. It was infuriating to watch a member of the law enforcement community — an institution I still have great respect for — publicly suggest things that I knew weren’t true.

D.C.'s former mayor Vincent Gray beat incumbent Yvette M. Alexander by a wide margin in the primary for the Ward 7 council seat on June 14. "I feel so excited that the people of Ward 7 have given me the opportunity to once again represent them," Gray said. (WUSA9)

The afternoon that Machen held his news conference was the day before my annual State of the District speech . After Machen’s announcement, I sat in my office in stunned shock. Then I assembled my key staff and told them it was imperative that we change the first section of my speech to address and refute Machen’s allegations. We made the revisions, but as I delivered the speech, a question kept resonating in my head: “How can I deliver this speech in a believable way when the U.S. attorney just accused me of engaging in a conspiracy with a serial criminal?”

It was enormously difficult to remain focused, but I knew I had to, because so much was at stake. I had no doubt these announcements were deliberate, seeking to undermine my chances for reelection. Yet despite the fact that I suspected ulterior motives, despite the indisputable reality that our city was doing very well and despite the untruths that had been told, Machen and his colleagues were engineering my defeat. It was simultaneously infuriating and dispiriting.

In the days that followed Machen Monday, my side of the story played second fiddle to Machen’s. News outlets emphasized sensational tidbits of “news” — the kingpin’s nickname and allusions to evidence that was never produced — but neglected their role as skeptics. The Washington Post editorial page reinforced Machen’s allegations and directed readers to reject me.

Fortunately for Clinton, The Post and most other media organizations are taking a different position today. There are more voices in the press saying Comey was wrong, if not reckless, to intervene in the closing days of an election — some raising the prospect that Clinton might be defeated but never charged with any wrongdoing, let alone convicted. This is precisely what happened in my situation.

Elections must be contested on a level playing field. The Justice Department understands this and has guidelines designed to avoid the appearance of meddling.

Few institutions have the power to hold the Justice Department in check. One institution that could is the press. Reporters did not object to the timing of Machen Monday until months after the fact . To this day, few news organizations have revisited or investigated the matter. In other words, no one held the Justice Department to account.

It should come as no surprise, therefore, that we are witnessing a repeat performance.

Perhaps the outcry over Comey’s actions will result in stricter enforcement of rules or repercussions the next time Justice Department officials inappropriately and unnecessarily inject themselves into elections.