A judge Thursday ordered President Donald Trump to pay $2 million to an array of charities as a fine for misusing his own charitable foundation to further his political and business interests.

New York state Judge Saliann Scarpulla imposed the penalty after the president admitted to a series of abuses outlined in a lawsuit brought against him last year by the New York attorney general’s office.

Among other things, Trump acknowledged in a legal filing that he allowed his presidential campaign staff to coordinate with the Trump Foundation in holding a fundraiser for veterans during the run-up to the 2016 Iowa caucuses.

In a defiant statement issued Thursday evening, though, Trump suggested he was neither sorry nor in the wrong.

“I am the only person I know, perhaps the only person in history, who can give major money to charity ($19M), charge no expense and be attacked by the political hacks in New York State,” he wrote.

He assailed a series of Democratic attorneys general of New York who were involved with the suit, saying they should have spent their time investigating the Clinton Foundation.

“It has been 4 years of politically motivated harassment,” Trump said.

The president’s foundation will be dissolved and its $1.7 million in remaining funds will be given to other nonprofits, under agreements reached by Trump’s lawyers and the attorney general’s office.

As part of those agreements, made public Thursday, the two sides left it up to the judge to decide what penalty Trump should pay.

Trump’s fine and the charity’s funds will be split evenly among eight organizations, including Citymeals on Wheels, the United Negro College Fund and the U.S. Holocaust Memorial Museum.

Trump also accepted restrictions on his involvement in other charitable organizations. His three eldest children, who were members of the foundation’s board, must undergo mandatory training on the duties of those who run charities.

Charities are barred from getting involved in political campaigns, but in weighing the Iowa fundraiser, Scarpulla gave the president credit for making good on his pledge to give $2.8 million that his charity raised to veterans’ organizations.

Instead of fining him that amount, as the attorney general’s office wanted, the judge trimmed it to $2 million and rejected a demand for punitive damages and interest.

The Trump Foundation said it was pleased by those decisions, claiming that the judge “recognized that every penny ever raised by the Trump Foundation has gone to help those most in need.”

Trump Foundation lawyer Alan Futerfas said the nonprofit has distributed approximately $19 million over the past decade, including $8.25 million of the president’s own money, to hundreds of charitable organizations.

© The Associated Press. All rights reserved.