It’s come to this: The FBI, America’s premier law enforcement agency, just had to decide whether to investigate one of its own Twitter accounts to see if it had an anti-Hillary Clinton bias.

The account in question, @FBIRecordsVault, burst into the news earlier this week after abruptly posting records related to Bill Clinton’s last-minute — and deeply controversial — pardon of financier Marc Rich. An FBI official said in an interview that the bureau’s Office of Professional Responsibility referred the matter to its Inspection Division for a possible investigation into whether anyone in the FBI had intentionally released the documents to hurt Hillary Clinton.

The official said the bureau’s internal watchdog opted against opening a formal investigation. Still, the fact that such a decision even had to be made highlights the crisis engulfing the bureau in the days since FBI Director James Comey stunned observers inside and outside the bureau by notifying Congress just 11 days before the election that he was renewing the dormant probe into Clinton’s private email server.

Comey has since come under sustained criticism from law enforcement veterans and lawmakers from both parties who believe he broke with longstanding Justice Department policies by directly intruding into the presidential race — and potentially impacting its outcome.

“There’s a longstanding policy of not doing anything that could influence an election,” George J. Terwilliger III, a deputy attorney general under President George Bush, told the New York Times last week. “Those guidelines exist for a reason. Sometimes, that makes for hard decisions. But bypassing them has consequences.”

Comey dropped another bombshell Sunday when he released a new letter to lawmakers saying the FBI had seen nothing in its review of the newly discovered trove of emails that would change his July recommendation that Clinton not face criminal charges.

Voters have spent days being barraged by round-the-clock coverage of his first letter, however, and Sunday’s quasi-retraction could be way too little, too late. That’s particularly true for the millions of Americans who have cast early ballots since Comey made his announcement.

The FBI chief also hasn’t been the only member of the FBI bureau stepping into the election. Earlier this week, unnamed sources within the bureau told the Wall Street Journal that some FBI agents believed they had enough evidence to begin an aggressive investigation into a potential pay-to-play scheme at the Clinton Foundation, but were overruled by more senior officials.

Another anti-Clinton leak came Thursday, when sources thought to be disgruntled FBI officials told Fox News that an indictment was coming in the Clinton Foundation case. The story gave Trump a new talking point, dominated Fox’s primetime news programming, and rocketed across the conservative media before being debunked by an array of other media outlets. By that point, though, the damage had already been done.

Taken together, it’s easy to come away with the conclusion that the FBI is out to get Hillary Clinton. The truth, though, is far more complicated. The FBI isn’t a monolith, and it isn’t the bureau as a whole that is targeting Clinton. Experts who study the FBI believe the leaks are coming from a small clique of agents who profoundly distrust Clinton and believe she deserves to be punished for what they see as a long record of ethically dubious behavior.

“Comey has unleashed a lot of the bad behavior by people down the line by signaling that it’s okay to treat Hillary Clinton differently,” says Matthew Miller, a Democrat who formerly served as a spokesperson for the Justice Department. “There certainly seem to be FBI agents who have taken a really hard partisan line and are just kind of blinded by their anger and hatred toward Hillary Clinton.”

The recent series of FBI leaks are particularly worrisome because they raise the prospect of a state security agency equipped with the full resources and investigative might of the federal government working to interfere in the elections. The FBI is so powerful — it can, with court approval, issue subpoenas, tap phones, intercept emails and conduct round-the-clock surveillance — that even a small coterie of its agents can find ways of influencing the political process. That’s the kind of thing we normally see in autocracies like Egypt or Turkey, not here in the United States.

It’s impossible to know how many agents support Trump, and the anti-Clinton leaks are likely the result of only a tiny minority of the bureau. Still, the fact that a small fraction of the FBI’s workforce has felt free to take steps that could impact the election is profoundly alarming. Comey stumbled by personally entering the political fray. His bigger mistake may have come from signaling to other agents that they could do the same.

Even Republicans think James Comey wrongly interfered in the election

Comey released his letter about the Clinton email probe over the objections of his higher-ups at the Justice Department, and despite the fact that the move violated two separate and long-standing policies. The first calls for never discussing ongoing criminal investigations. The second, repeated every four years, is to avoid taking steps within 60 days of an election that could influence the vote and appear to inject partisanship into the FBI’s work.

“We must be particularly sensitive to safeguarding the department’s reputation for fairness, neutrality and nonpartisanship,” then-Attorney General Eric Holder said in a 2012 memo.

Comey did so anyway, triggering sharp criticism from former senior FBI and DOJ officials from both parties. Two of Holder’s most recent Republican predecessors, Alberto Gonzales and Michael Mukasey, have also accused the FBI chief of making a serious error in judgement.

The FBI chief’s decision has also spurred a sustained counterattack from the Clinton campaign, which has repeatedly pointed out that Comey took the step despite having earlier argued against publicly accusing Russia of hacking a variety of Democratic targets. He claimed this was to avoid influencing the race by bolstering Clinton’s contention that Moscow was trying to help Trump win the presidency. In a conference call with reporters Monday, Clinton campaign manager Robby Mook said Comey’s reluctance to name Russia was “a blatant double standard.”

Outside experts on the FBI say Comey has made a serious and perhaps irreparable mistake.

“His actions were unprecedented, unethical, shocking, and have apparently led to chaos within the bureau, an unprecedented number of leaks, and chaos in our election cycle,” said Douglas Charles, a history professor at Penn State.

Charles, the author of a book about J. Edgar Hoover’s FBI, said Comey has a long history with the Clintons that may have left him with a “personal grudge or underlying or subsumed political motive” to try to derail Hillary Clinton’s candidacy.

He noted that Comey had helped probe the 1990s-era Whitewater real estate scandal, which focused heavily on Hillary Clinton’s financial dealings and willingness to fully cooperate with investigators, and oversaw the Marc Rich prosecution in the late 1980s. (Comey said he was “stunned” by Bill Clinton’s decision to pardon the financier.)

The FBI chief’s defenders say that Comey felt he had no choice but to send the letter because he’d promised to keep lawmakers abreast of any new developments in the email server case, and the discovery of Clinton-related emails on the laptop of the estranged husband of Clinton confidante Huma Abedin certainly qualified.

They also argue that Comey would have been accused of covering up for Clinton if he sat on the information until after the election. One unnamed “senior law enforcement official” told NBC News that Comey had sent the letter “out of an abundance of caution.”

Comey has had a long reputation for personal integrity and nonpartisanship, and we may never definitively know why he chose to publicly bash Clinton’s handling of her emails even though he said he’d found no evidence of criminal wrongdoing; decided to testify on Capitol Hill about the probe and give lawmakers access to the bureau’s investigative files; and opted to ignore the wishes of his bosses and release his new letter.

But his actions appear to have triggered a cascade of other anti-Clinton leaks by agents who, rightly or wrongly, believe he gave them the green light.

The FBI’s problems start at the top, but they don’t end there

The FBI has what experts like Charles and Miller describe as a disproportionate number of Republicans and other conservatives. It’s also one where, if media reports are to be believed, some agents are openly and vocally supporting Trump’s candidacy.

In the words of one anonymous agent quoted by the Guardian, some FBI personnel see Clinton as “the anti-Christ,” and “the reason why they’re leaking is they’re pro-Trump.” The FBI, the agent said, “is Trumpland.”

The willingness of some agents to break with FBI policies about discussing open investigations in the run-up to an election has been evident for days. The first leak came over the weekend, when unnamed sources told the Wall Street Journal about a bitter power struggle between agents in the FBI’s New York office who have been probing the Clinton Foundation and career prosecutors in Washington charged with deciding whether to bring a case.

According to the Journal, the FBI investigators believed they had enough evidence to merit an aggressive investigation, using subpoenas and other powerful tools, into whether donors to the Clinton Foundation had received preferential treatment from Hillary Clinton’s State Department. Prosecutors in Washington, backed by some senior officials at the FBI, refused to greenlight the probe.

All government agencies leak, but comments from unnamed FBI officials carry extra weight because many Americans are predisposed to trust law enforcement more than they do other institutions like Congress or the White House. That’s part of what makes the FBI’s involvement in partisan squabbling so different — and so dangerous.

The next apparent leak came Thursday, when Fox News, citing unnamed sources, reported that indictments were “likely” in the Clinton Foundation case.

“We talked to two separate sources with intimate knowledge of what's going on with the FBI investigations,” Fox News anchor Bret Baier said on air to his colleague Brit Hume. “The investigations will continue, there is a lot of evidence. And barring some obstruction in some way, they believe they will continue to likely an indictment."

According to a detailed report by CNN, other news outlets almost immediately began pushing back at the Fox News story and saying no indictments were coming. Fox News originally stood by the reporting, but Baier later said he had spoken “inartfully,” implicitly walking back his own initial reporting. Baier made the retraction explicit on Friday, calling his report “a mistake.” But the damage was done — Baier’s apology is getting much less coverage than his initial comments. As of Friday afternoon, the original, inaccurate story still appeared on Breitbart and Sean Hannity’s webpage.

Some in the Clinton campaign, meanwhile, say the Fox News report was leaked by the FBI to damage Clinton and ensure that negative stories about the foundation dominated another of the final days before the election. In a statement Thursday night, campaign spokesperson Brian Fallon called on the FBI to publicly "put a stop to these baseless Fox News reports."

Douglas, the Penn State professor, says that the negative impact of Comey’s letter to Congress has been significantly magnified by the recent series of leaks.

“It seems unreasonable to conclude Comey is directly behind them, but it is reasonable to conclude he has lost control over the FBI,” Douglas said. “The leaks probably reflect a fractured FBI culture under his leadership where some partisan agents or employees have seen the director act in an apparently political manner and felt compelled or motivated to do the same, revealing their political biases, via leak.”

Miller, the former Justice Department spokesperson, said some FBI agents have “taken a really hard partisan line and are just kind of blinded by their anger and hatred toward Hillary Clinton.

“Comey through his conduct has sent a signal that it’s okay to treat Hillary differently,” he said. “When you see the director act that way, it frees up other agents to do the same.”

Kelly Langmesser, a spokesperson for the FBI’s New York field office, declined to comment on whether the bureau had opened an internal probe designed to find the leakers in her office who may have spoken to the Wall Street Journal and Fox News.

The end of the election is being dominated by leaks. That’s a problem.

We’re nearing the end of one of the nastiest presidential campaigns in US history, where the nominee of a major American political party has called for jailing his opponent, said he might not concede if he’s defeated at the ballot box, and used openly anti-Semitic rhetoric to assert that a shadowy cabal of international financiers was working to rig the election and destroy the US.

The final days of the election, though, aren’t being used for a discussion of any of those issues, nor of the deep and substantive policy differences between Trump and Clinton. Instead, they’re being dominated by leaks, counter-leaks, and a growing partisan war over the independence of the FBI.

That is a dangerous path for the country to be going down, regardless of who wins the White House. If Trump is elected, he could theoretically use one of America’s most powerful security services to probe his rivals. Even if no charges were brought, simply complying with federal investigations is so costly that such probes would have a chilling effect on political dissent.

Trump and his top aides wouldn’t even have to explicitly order the FBI to take such steps. As Benjamin Wittes of the Brookings Institution wrote in an essay for the blog Lawfare this past summer, a Trump administration would simply need to make sure that loyalists were put into key jobs like attorney general that shared the new president’s desire to go after his enemies and were able to read between the lines of what Trump said to understand what he wanted done.

A hostile FBI could also help derail a Clinton presidency. Hillary Clinton, if elected, would take office with at least two open FBI investigations into the activities of her family and closest aides. A constant series of leaks about the probes could damage Clinton’s public standing while handing Republicans on Capitol Hill new material to use in what GOP leaders have already said will be years of Congressional investigations.

The FBI’s intrusion into politics also carries risks for the bureau itself. The FBI’s ability to do its work depends on the public at large, and the bureau’s overseers on Capitol Hill, seeing it as a nonpartisan entity that uses its vast powers without regard to political party or affiliation. An FBI that came to be seen as an extension of a Trump White House or a partisan opponent of a Clinton one would forfeit much of that moral and political standing.

Earlier this week, I asked Steven Aftergood, the head of the Federation of American Scientists' government secrecy program, about Comey and the other anti-Clinton leaks seeming to come out of the FBI.

“The FBI is in a bad place because whether by design or not it’s interfering in the presidential campaign,” he said at the time. “People are arguing about Comey’s motivations, but speculation aside, the reality is that the FBI’s actions in the final weeks of the election have taken center stage, and that’s not where they should be.”

Aftergood made those comments Tuesday, before this latest round of anti-Clinton leaks by the FBI. His description of a bureau largely out of control was true then, and seems even truer now. There's no question disgruntled agents have violated the FBI's internal rules against secrecy. In less than a week, we’ll also know whether they impacted one of the most climactic elections in American history.