NEW YORK (AP) — President Donald Trump's charitable foundation reached a deal Tuesday to go out of business, even as Trump continues to fight allegations he misused its assets to resolve business disputes and boost his run for the White House.

New York's attorney general and lawyers for the Trump Foundation agreed on a court-supervised process for shutting down the charity and distributing about $1.7 million in remaining funds to other nonprofit groups.

The agreement resolved one part of the legal drama surrounding Trump, whose campaign, transition, inauguration and real estate empire are all under investigation.

Attorney General Barbara Underwood's lawsuit alleging Trump and his family illegally operated the foundation as an extension of his businesses and his presidential campaign will continue.

The lawsuit, filed last spring, seeks $2.8 million in restitution and a 10-year ban on Trump and his three eldest children — Donald Jr., Eric and Ivanka — from running any charities in New York.

In a statement Tuesday, Underwood cited "a shocking pattern of illegality involving the Trump Foundation — including unlawful coordination with the Trump presidential campaign, repeated and willful self-dealing, and much more."

The foundation operated as "little more than a checkbook to serve Mr. Trump's business and political interests," she said.

Lawyers for the foundation have said any infractions were minor.

Trump pledged to dissolve the three-decade-old foundation and donate its funds to charity after his 2016 election, but that was only after it found itself under investigation in New York state. The attorney general's office said it would have been "unacceptable" to let the foundation fold without close supervision from a judge.

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.

The agreement was reached after a New York judge last month rejected arguments from the foundation's lawyers that the lawsuit was politically motivated and should be thrown out.

Once the judge approves the deal to dissolve the charity, the two sides will have 30 days to provide her with a list of nonprofit organizations that should get the remaining funds. Each charity will get the same amount, and the attorney general's office will have the right to reject ones it deems unfit to receive funds.

In her lawsuit, Underwood alleged that Trump used the foundation to help bolster his campaign by giving out big grants of other's people money to veterans organizations during the run-up to the Iowa caucuses, the first presidential nominating contest of 2016.

Trump was also accused of 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, Florida, 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; $10,000 to buy a 6-foot (1.8-meter) portrait of Trump at a charity auction; and $5,000 for ads promoting Trump's hotels in the programs for charitable events.

Underwood sued the Trump Foundation after taking over for fellow Democrat Eric Schneiderman, who resigned in May amid allegations he abused women. Schneiderman started investigating the foundation in 2016 and ordered it to stop fundraising in New York after The Washington Post reported that some of its spending personally benefited the presidential candidate.

Underwood has referred her office's findings to the IRS and the Federal Election Commission. Those agencies have not commented on the matter.