A veteran IRS employee has been charged with leaking the banking records of President Trump's onetime personal attorney, Michael Cohen, to Michael Avenatti, the attorney for adult film star Stormy Daniels, federal prosecutors announced Thursday.

John C. Fry, 54, was charged with one count of unlawful disclosure of information obtained from so-called Suspicious Activity Reports (SARs) and was released on $50,000 bond after appearing in federal court in San Francisco.

According to an affidavit by Linda Cieslak, a special agent with the U.S. Department of Treasury, Fry repeatedly searched law enforcement databases for information relating to Cohen. Fry, an investigative analyst for the IRS' law enforcement arm who has worked for the agency since 2008, is accused of gaining access to five SARs, which are filed by banks when transactions are spotted that raise questions about possible financial misconduct.

AVENATTI GIVES UP CONTROL OF FIRM AFTER BEING ACCUSED OF HIDING MILLIONS: REPORT

One of the reports Fry allegedly accessed showed Cohen's Essential Consultants had received a total of $500,000 from Columbus Nova, a company associated with Viktor Vekselberg, a Russian oligarch who donated money to Trump's inauguration fund. Other payments to Essential Consultants came from AT&T ($200,000) and pharmaceutical company Novartis (approximately $399,920).

Cieslak said Fry called Avenatti from his cellphone three separate times and relayed the information from the SARs to the attorney verbally. The agent added that Fry admitted to doing so when investigators confronted him in November.

The affidavit says Avenatti made the information he obtained from Fry public on Twitter May 8, writing: "Mr. Trump and Mr. Cohen have a lot of explaining to do." Avenatti declined to say how he obtained the records, telling Fox News at the time: "That’s my work product and will not be disclosed."

AVENATTI RUNS LAW FIRM LIKE 'PONZI SCHEME,' FORMER CLIENT CLAIMS IN COURT FILING

The affidavit also includes exchanges between Fry and reporter Ronan Farrow, who wrote a story for the New Yorker magazine about the motives behind the leak. Farrow, who is identified as "Reporter-1" in the affidavit, wrote in an article published May 16 that the law enforcement official who released the report had grown concerned after he was unable to find two other reports on Cohen's financial activity that he believed should have been in a government database.

According to Cieslak, Fry told investigators in November that Farrow had contacted him to confirm information supplied to Farrow by Avenatti.

Avenatti tweeted Thursday evening: "Neither I nor R. Farrow did anything wrong or illegal with the financial info relating to Cohen’s crimes (the courts have found that the [federal Bank Secrecy Act] does not apply ... And if we did (we didn’t), then every reporter in America would be jailed and unable to do their job."

CLICK HERE TO GET THE FOX NEWS APP

At the time of the disclosures, Avenatti was locked in a legal battle with Cohen over a $130,000 payment to Daniels in the days leading up to the 2016 presidential election. The payment was made in exchange for Daniels' silence about an alleged sexual encounter with the married Trump that took place more than a decade ago. Cohen pleaded guilty last August to federal campaign finance and other violations and has been sentenced to three years in prison.

If convicted, Fry faces up to five years in prison and a $250,000 fine. His next court appearance is scheduled for March 13.

The Associated Press contributed to this report.