WASHINGTON (AP) — A former contractor for the Internal Revenue Service charged with leaking tax information to news outlets about former President Donald Trump and thousands of the country’s wealthiest people pleaded guilty to a federal charge Thursday in an agreement with prosecutors.

The Justice Department charged Charles Edward Littlejohn, 38, of Washington, D.C., with stealing tax return information and giving it to two news outlets between 2018 and 2020.

U.S. District Judge Ana Reyes said she was deeply troubled by his actions that affected Trump and thousands of other people. “When we have people, for whatever reason, take the law into their own hands society doesn’t function,” she said. “Make no mistake, this was not acceptable. If anyone tells you the ends justify the means, they’re wrong.”

Littlejohn pleaded guilty to one count of unauthorized disclosure of tax returns and return information. The count carries up to five years in prison, but the ultimate sentence will be decided by the judge. Trump attorney Alina Habba pushed back against the plea deal and called for a long sentence. Littlejohn is set to be sentenced Jan. 29.

Attorney General Merrick Garland said in a statement that Littlejohn “broke federal law and betrayed the public’s trust.”

Defense attorney Lisa Manning declined to comment.

The outlets were not named in the charges, but the description and time frame align with stories about Trump’s tax returns in The New York Times and reporting about wealthy Americans’ taxes in the nonprofit investigative journalism organization ProPublica.

The 2020 New York Times report found Trump paid $750 in federal income tax the year he entered the White House and no income tax at all some years thanks to colossal losses. Six years of his returns were later released by the then-Democratically controlled House Ways and Means Committee.

ProPublica, meanwhile, reported in 2021 on a trove of tax-return data about the wealthiest Americans. It found the 25 richest people legally pay a smaller share of their income in taxes than many ordinary workers do.

Both publications have declined to comment on the charges, and ProPublica reporters previously said they didn’t know the identity of the source. The stories sparked calls for reform on taxes for the wealthy — and calls for investigations into the leaking of tax information, which has specific legal protections.

The IRS has said any disclosure of taxpayer information is unacceptable and the agency has since tightened security.