"Mr Trump owed fiduciary duties to the Foundation," Scarpulla wrote in an order, meaning duties to safeguard the foundation's money. "Mr Trump breached his fiduciary duty to the Foundation."
New York Attorney General Letitia James, a Democrat, had asked Scarpulla to make Trump pay US$2.8 million, but Scarpulla said she was reducing that payment to US$2 million.
The reason: the president had agreed to mend his ways, agreeing to extra monitoring of any future charitable activities in New York, so that "the conduct which engendered this petition should not occur in the future," Scarpulla said.
Trump's three eldest children - Ivanka, Donald Jr. and Eric - were also named in the original lawsuit, because they were officially board members at the Trump Foundation. The board was required to oversee the foundation's spending. In reality, it did not meet at all for 19 years, from 1999 to 2018.
The three children were required to take an "in-person interactive" training class in how to be a better board member, and the suit against them was dismissed, court documents say.
In a statement, James called the settlement "a major victory."
"My office will continue to fight for accountability because no one is above the law - not a businessman, not a candidate for office, and not even the President of the United States," James said in a statement.
In his own statement, Trump's attorney, Alan Futerfas, attacked James's lawsuit as "politically motivated." (It was filed by James' predecessor, Barbara Underwood, an unelected career official who took over after Attorney General Eric Schneiderman, a Democrat, resigned in scandal).
"Now that this matter is concluded, the Trump Foundation is proud to make this additional contribution," Futerfas said. The money from Trump will go to charities including the Children's Aid Society, the United Negro College Fund, and the US Holocaust Memorial Museum, according to the attorney general's office.
The order for Trump to pay comes follows extensive reporting in The Washington Post about alleged wrongdoing at the foundation.
The Post's coverage began in early 2016 after a Post reporter saw Trump give away a Trump Foundation check during a campaign rally in Waterloo, Iowa. That was notable because federal law prohibits charities' money from being used to help political campaigns.