A New York judge has ordered Donald Trump to pay $2 million US to settle a lawsuit alleging he misused his charitable foundation to further his political and business interests before he became U.S. president.

New York state Judge Saliann Scarpulla imposed the penalty in connection with a lawsuit brought against Trump by the New York attorney general's office over the handling of the Trump Foundation's assets.

Among other things, the judge ruled that Trump improperly allowed his presidential campaign staff to work with the foundation in holding a fundraiser for veterans' charities in the run-up to the 2016 Iowa caucuses. The event was designed "to further Mr. Trump's political campaign," Scarpulla said.

In the settlement, Trump admitted, among other things, to have improperly arranged for the charity to pay $10,000 for a six-foot portrait of him. He also agreed to pay back $11,525 in the organization's funds he spent on sports memorabilia and champagne at a charity gala. He also agreed to restrictions on his involvement in other charitable organizations.

The agreement was an about-face for Trump. He and his lawyers have blasted the lawsuit as politically motivated, and he tweeted, "I won't settle this case!" when it was filed in June 2018.

Thursday evening, he tweeted that the attorney general was mischaracterizing the settlement "for political purposes."

STATEMENT FROM PRESIDENT DONALD J. TRUMP <a href="https://t.co/EktztHfLk6">pic.twitter.com/EktztHfLk6</a> —@realDonaldTrump

Trump's fine and the charity's remaining $1.7 million funds will be split evenly among eight organizations, including City Meals-on-Wheels, the United Negro College Fund and the U.S. Holocaust Memorial Museum.

New York Attorney General Letitia James said resolution of the case is a "major victory in our efforts to protect charitable assets and hold accountable those who would abuse charities for personal gain.

"No one is above the law — not a businessman, not a candidate for office and not even the president of the United States," said James, a Democrat.

Trump's 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 Trump credit for making good on his pledge to give $2.8 million of the money 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.

At the time of the Iowa fundraiser, Trump was feuding with then-Fox News anchor Megyn Kelly and refusing to participate in the network's final Republican presidential primary debate before the Iowa caucuses.

Trump with his three oldest children, from left: Donald Trump Jr., Ivanka Trump and Eric Trump. All three have been ordered to do mandatory training as part of the settlement. (Mike Cassese/Reuters)

Instead, he held a rally at the same time as the debate at which he called on people to donate to veterans' charities. The foundation acted as a pass-through for those contributions.

James said the evidence of banned co-ordination between campaign officials and the foundation included emails exchanged with then-Trump campaign manager Corey Lewandowski.

In one email, a Trump company vice-president asked Lewandowski for guidance on precisely how to distribute the money raised.

Trump also admitted in the agreements to directing that $100,000 in foundation money be used to settle legal claims over an 80-foot flagpole he had built at his Mar-a-Lago resort in Palm Beach, Fla., instead of paying the expense out of his own pocket.

In addition, the foundation paid $158,000 to resolve a lawsuit over a prize for a hole-in-one contest at a Trump-owned golf course, and $5,000 for ads promoting Trump's hotels in the programs for charitable events. Trump admitted these transactions were also improper.