For indispensable reporting on the coronavirus crisis, the election, and more, subscribe to the Mother Jones Daily newsletter.

A New York judge ordered President Donald Trump to pay $2 million to settle claims that he used his personal foundation as a piggybank to advance his personal and political interests. The settlement stems from a lawsuit filed last year by New York’s attorney general, which accused the president of a pattern of “persistently illegal conduct” involving the Donald J. Trump Foundation. Donald Jr., Eric, and Ivanka were also named in the case.

After the lawsuit was filed, Trump defiantly insisted he would never settle the case:

The sleazy New York Democrats, and their now disgraced (and run out of town) A.G. Eric Schneiderman, are doing everything they can to sue me on a foundation that took in $18,800,000 and gave out to charity more money than it took in, $19,200,000. I won’t settle this case!… — Donald J. Trump (@realDonaldTrump) June 14, 2018

But settle he did. Last December, Trump agreed to shut down the foundation and give away its remaining money to a list of approved charities, including the United Way, the United Negro College Fund, and the Holocaust Museum. The settlement left the decision on how much Trump should pay in restitution for misusing his charity to the judge in the case, New York Supreme Court Judge Saliann Scarpulla. Scarpulla ruled on Thursday that $2 million—which will be distributed among the same group of approved charities—would be sufficient.

The lawsuit alleged that the Trumps rarely, if ever, held board meetings or discussed foundation business and that much of the money the foundation disbursed was used to help Donald Trump—not serve some broader charitable purpose. The largest donation the foundation made was a $264,000 payment to the Central Park Conservancy in 1989, a contribution that went toward the rehabilitation of a fountain outside of a Trump property in New York City. The foundation was also used to purchase a football helmet signed by Tim Tebow for $12,000 and to buy at least one portrait of Trump, which was later hung in one of the president’s resorts.

In her ruling approving the final $2 million payment and settlement, Scarpulla repeatedly pointed to Trump’s misuse of the foundation during the 2016 presidential campaign. In January 2016, Trump, fueding with Fox News, skipped the cable news channel’s Iowa debate and instead counter-programmed a charity fundraiser, ostensibly to benefit veterans, in Des Moines. The event raised more than $2 million, but documents filed in the lawsuit show that Trump’s foundation ceded total control of how the money would be disbursed to Trump’s campaign.

“Is there any way we can make some disbursements this week while in Iowa?” then–Trump campaign manager Corey Lewandowski wrote in an email to a Trump Organization executive at the time. The following week, Trump handed out $500,000 in donations from the foundation during a political event. He went on to make doling out checks to local charities part of his campaign-rally routine.

In a statement, New York Attorney General Letitia James said the ruling was a victory for the rule of law.

“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,” she said. “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.”

In addition to the $2 million payment, Trump was also ordered to reimburse the foundation $11,525 to cover the cost of paying for charity auction items and champagne. James’ office described the auction items as “sports paraphernalia,” an apparent reference to the Tebow helmet.

Under a previously agreed part of the settlement, Trump admitted he misused funds, paid back the cost of purchasing the portrait, and agreed to restrictions on any new charity he might start in the state of New York. Donald Jr., Eric, and Ivanka Trump, meanwhile, were ordered to attend mandatory training sessions on nonprofit management.