FBI Director James Comey testifies on Capitol Hill in Washington, Thursday, July 7, 2016, before the House Oversight Committee to explain his agency's recommendation to not prosecute Hillary Clinton, now the Democratic presidential candidate, over her private email setup during her time as secretary of state, . (AP Photo/J. Scott Applewhite)

Criticism of FBI Director James Comey over his handling of the investigation of Hillary Clinton’s use of a private email server as secretary of state has been building for months, but his latest actions have set off a series of leaks from within the agency that threaten to undermine his authority and his ability to effectively lead the FBI during the next administration.

Comey reportedly wrote the letter because he felt an obligation after testifying before those committees that he would notify them of any new developments in the case. Some reports also indicate that he feared the existence of the emails would be leaked and would lead to allegations of a cover-up if he did not say anything.

Within hours after Comey’s letter was released by Republicans, the FBI did begin to spring leaks. First came further information about the unrelated investigation, which turned out to be the FBI’s probe of Anthony Weiner’s alleged sexting with an underage girl.

Emails found on a laptop used by Weiner and his wife, Clinton aide Huma Abedin, were reportedly what spurred Comey to send the letter. Initial reporting varied, but it now appears there were thousands of messages on the device that investigators believe may have been sent to or from on Clinton’s server.

Over the weekend, the flow of leaked information that seemed intended to either help Clinton or Republican nominee Donald Trump accelerated. The flood of anonymously sourced information about ongoing investigations has revealed a number of things about both campaigns that, if true, would be of interest to voters. Among them:

Multiple FBI field offices have pursued investigations of the Clinton Foundation for possible corruption and conflicts of interest. Department of Justice officials reportedly denied requests to authorize more aggressive methods to build a case.

Investigations have so far found no direct link between Trump and the Russian government. Officials reportedly believe Russia’s meddling in the U.S. election is aimed at disrupting the process rather than aiding Trump personally.

Comey did not want the FBI to be associated with the statement from U.S. intelligence agencies that Russia is believed to be behind the hacking of Democratic organizations and operatives. Some reports say this is because he feared the announcement would somehow influence the election, but others say it was due to the impact it could have on FBI investigations and methods.

The FBI declined to comment on any of these leaks or whether the agency is doing anything to plug them up.

David Gomez, a former FBI agent who spent nearly 30 years with the bureau, called the level of leakage to the press in recent days “unprecedented.”

“To leak the information about an active investigation is a very serious offense within the FBI, so I personally am questioning how many of these sources are actually active duty agents working on the relevant cases that they’re talking about,” Gomez said.

Matt Cecil, an expert on FBI history and author of “Branding Hoover’s FBI: How the Boss’s PR Men Sold the Bureau to America,” said the leaks are a somewhat self-inflicted wound on Comey’s part since his letter to Congress sparked such a firestorm of speculation at a crucial point in the race.

“Maybe it was inevitable given the candidates we have, but Comey’s ill-timed notification seems to have set off a frenzy of leaks as various players try to repair their damaged reputations. You have to wonder: How are voters supposed to process this mess?” said Cecil, currently dean of the College of Arts and Humanities at Minnesota State University, Mankato.

Douglas Charles, author of “The FBI's Obscene File: J. Edgar Hoover and the Bureau's Crusade Against Smut,” said Hoover’s FBI played politics and exerted influence on lawmakers when it suited his interests, but it did so quietly.

“Hoover did it all obsequiously and carefully, always certain to protect is FBI’s carefully crafted public image,” he said.

The very public leaking of information is “deeply concerning,” said Charles, a professor of history at Penn State Greater Allegheny, and it suggests internal divisions at the bureau. The leaks leave the impression of an FBI in crisis, with warring partisan factions pressuring and contradicting the director from behind the curtain.

Comey has, over the last four months, managed the rare feat of infuriating supporters of both major party presidential candidates. His decision not to recommend criminal charges for Clinton over her handling of classified information saved her campaign from a fatal blow, but his actions since have raised questions from both sides.

The July announcement that the FBI was not recommending criminal charges for Clinton or her aides was obviously welcomed by her supporters, but it was widely denounced by Republicans. Trump and Republican leaders have since accused Comey of corruption and alleged that he perjured himself in congressional testimony by insisting that Clinton was not treated differently from others.

While many Democrats expressed concern that Comey’s extensive public statements about the case at the time and his decision to release investigative documents normally kept secret were mistakes that set bad precedents for the future, they had generally praised Comey’s integrity and the conclusion he reached in the case until last Friday.

Now, Senate Minority Leader Harry Reid is accusing Comey of violating the Hatch Act and other Democrats are urging the director to resign.

Matthew Miller, a former DOJ public affairs official, has been harshly critical of Comey since the director set aside FBI rules against commenting on ongoing cases to defend investigators’ work on the Clinton case in July. He also objected to Comey’s handling of the latest development.

“With each step, Comey moved further away from department guidelines and precedents, culminating in Friday’s letter to Congress,” Miller wrote in a Washington Post op-ed. “This letter not only violated Justice rules on commenting on ongoing investigations but also flew in the face of years of precedent about how to handle sensitive cases as Election Day nears.”

All of this puts Comey in a complicated position going forward. The easy answer may be for him to step down, but Gomez said that would only further undercut the credibility and independence of the agency.

“I think that the worst thing that could happen out of this whole email debacle is that Comey resign or be forced to resign because that puts you back into the cycle where the president appoints their own FBI director,” he said.

Comey was appointed by President Obama in 2013 with the expectation that he would serve for 10 years, through the next president’s first term, protecting him from the pressures of partisanship.

“If you’re a law enforcement professional, you’re used to getting it from both sides anyway,” Gomez said. “… It comes with the territory and I’m hoping that Comey has the strength of character and the ethics, which I think he does, to remain in that post until his term is up. There’s a reason Congress made it a 10-year term.”

Cecil agreed that it would be unfortunate for election year politics to drive out the head of the FBI.

“It would be a shame if we let politics, self-inflicted by Comey or not, determine the leadership of the FBI,” he said. “The bureau is too important to our national security to allow the FBI to be subject to the ebb and flow of politics.”

However, Charles said Comey has unnecessarily sown chaos by commenting on the Clinton investigation and doing so at a time that could influence the election. The FBI has a long history of effective public relations and of restoring its standing after controversies.

“To repair its reputation, I think that can only happen without Comey,” he said.

Gomez said much of the criticism currently being hurled at Comey and the FBI is driven by politics and does not reflect on Comey’s ability to do the job, even if he has proven unable to control the latest spate of leaks from within his agency.

“This is not an ethical problem for the director of the FBI… It’s going to end up speaking to the strength of the FBI as long as Mr. Comey’s able to ride it out,” he said.