A New York judge on Thursday ordered President Trump to pay a $2 million settlement to a number of nonprofits in a civil case alleging the Trump Foundation committed โ€œpersistentโ€ violations of the laws governing charitable organizations, according to a court filing.

The lawsuit from New York alleges that Trump and his three oldest children ran the charitable organization in a way that flouted federal and state campaign finance laws during the 2016 campaign season, including allowing the Trump campaign to organize a fundraising event for the foundation in Des Moines.

According to the suit, the Trump family violated the charitable foundationโ€™s tax-exempt status by turning it into โ€œlittle more than a checkbook to serve Mr. Trumpโ€™s business and political interests.โ€

Lawyers for the Trump Foundation denied the charges, saying, โ€œall of the money raised by the Foundation went to charitable causes to assist those most in needโ€ and argued that New York does not have jurisdiction over the president. The attorneys have also accused the state attorney generalโ€™s office of playing politics.

โ€œ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,โ€ State Supreme Court Justice Saliann Scarpulla wrote in her ruling.

Trump vowed in June, 2018 when the lawsuit was filed to fight the case, accusing โ€œsleazy New York Democratsโ€ of โ€œ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!โ€ the president wrote on Twitter.

The judgeโ€™s decision comes after the Trump Foundation in December agreed as part of the years-long New York investigation to dissolve under court supervision and give away its remaining assets after the New York attorney general accused the organization of โ€œa shocking pattern of illegality.โ€