NEW YORK (Reuters) - A New York state judge on Thursday ordered U.S. President Donald Trump to pay $2 million for misusing his namesake charitable foundation, resulting in funds being used to advance his 2016 presidential campaign.

Justice Saliann Scarpulla, of the state Supreme Court in Manhattan, directed the payment to eight non-profits, in connection with a lawsuit by the state’s attorney general against the president and three of his adult children over the now-dissolved Donald J. Trump Foundation.

President Trump defended the charity in a statement on Twitter, saying the foundation was an “incredibly effective philanthropy” that had made “some small technical violations.”

A spokesman for the Trump Foundation said it was pleased the court rejected the attorney general’s request for punitive damages.

The attorney general, Letitia James, said her office had also reached agreements with the foundation and its directors to end the June 2018 lawsuit, which was filed by her predecessor, Barbara Underwood.

James said Trump admitted to “personally misusing funds at the Trump Foundation,” which agreed last December to dissolve, and accepted limits on his activities if he created a new charity. James also said Trump’s children - Donald Jr., Eric and Ivanka - agreed to “mandatory training” on the duties of charity officials.

“The court’s decision, together with the settlements we negotiated, are a major victory in our efforts to protect charitable assets and hold accountable those who would abuse charities for personal gain,” James said in a statement.

Trump, in his statement, accused James of “deliberately mischaracterizing this settlement for political purposes.”

Underwood had filed suit after a 21-month probe that she said uncovered “extensive unlawful political coordination” between the Trump Foundation and Trump’s campaign. The lawsuit sought to recoup $2.82 million donated to the foundation in a 2016 Iowa fundraiser for military veterans, but which Underwood said Trump allowed his campaign to control.

Scarpulla agreed with the attorney general’s office that Trump had breached his fiduciary duty to the foundation.

“Mr. Trump’s fiduciary duty breaches included allowing his campaign to orchestrate the fundraiser, allowing his campaign, instead of the Foundation, to direct distribution of the funds, and using the fundraiser and distribution of the funds to further Mr. Trump’s political campaign,” she wrote.

The judge said that because the money ultimately went to support veterans, Trump should pay just $2 million, without interest, rather than the entire $2.82 million.

In refusing to award punitive damages, Scarpulla cited Trump’s agreement to take steps to avoid a recurrence.

The $2 million is expected to go to Army Emergency Relief, the Children’s Aid Society, City Meals-on-Wheels, Give an Hour, Martha’s Table, the United Negro College Fund, the United Way of the National Capital Area and the United States Holocaust Memorial Museum.