President Donald Trump has agreed to shut down his family's embattled Trump Foundation, following investigators' allegations the charity misused funds by directing them to Mr. Trump or his businesses. The attorney general alleged the foundation engaged in a "a shocking pattern of illegality."

New York Attorney General Barbara D. Underwood said in a statement the Trump Foundation had signed an agreement to dissolve the charity under court supervision. The attorney general will review and approve the process, including approving the charities slated to receive the foundation's remaining assets.

The attorney general's office filed a lawsuit in June accusing the Trump Foundation of misusing funds for personal benefit, including Trump Organization legal payments and Mr. Trump's 2016 presidential campaign. Among the claims: The foundation raised money at a nationally televised fundraiser in January 2016, then allowed Trump campaign staffers to dictate how the money was spent in grants.

Today’s stipulation accomplishes a key piece of the relief sought in our lawsuit earlier this year. Under the terms, the Foundation can only distribute its remaining charitable assets to reputable organizations that we have approved. https://t.co/YlvIBs7ZlN — NY AG Underwood (@NewYorkStateAG) December 18, 2018

The lawsuit, which seeks to bar Mr. Trump and his three eldest children from serving on the boards of other New York-based charities, will continue, the AG said in the statement. The lawsuit also seeks "millions in restitution" for what it said was a "a shocking pattern of illegality."

Get Breaking News Delivered to Your Inbox

The Trump Foundation functioned "as little more than a checkbook to serve Mr. Trump's business and political interests," Underwood said in the statement. "This is an important victory for the rule of law, making clear that there is one set of rules for everyone."

White House press secretary Sarah Sanders referred a question about the legal development Tuesday to the Trump Organization.

"Seeking to dissolve"

An attorney for the Trump Foundation, Alan Futerfas, objected to the attorney general's characterization of the charity and said it was an effort to "politicize" the issue.

"Contrary to the NYAG's misleading statement issued earlier today, the Foundation has been seeking to dissolve and distribute its remaining assets to worthwhile charitable causes since Donald J. Trump's victory in the 2016 Presidential election," he said in the statement.

It added, "Unfortunately, the NYAG sought to prevent dissolution for almost two years, thereby depriving those most in need of nearly $1.7 million."

The attorney's statement said the Trump Foundation has given away about $19 million during the last decade, including what Futerfas said was $8.25 million of Mr. Trump's money, to more than 700 charitable organizations.

Charity Navigator, a site that provides assessments of charities' operations, has a "high concern" advisory on the Trump Foundation, citing concerns raised about the Trump Foundation's "organizational legitimacy and/or federal tax law compliance."

Trump children

The NYAG lawsuit names Mr. Trump's three oldest children -- Donald Jr., Eric and Ivanka -- as participants in the foundation's alleged problems. All three have been listed as officers of the foundation, although the lawsuit claims they "failed to discharge their duties as directors with the degree of care, skill, prudence, diligence, and undivided loyalty required of them in."

None of the Trumps attended a single meeting to discuss the foundation's assets, liabilities, revenue or grants, the lawsuit claims. The board of directors failed to meet for an annual meeting since 1999, the lawsuit added.

Gifts to benefit Trump?

The gifts provided by the Trump Foundation sometimes helped his own businesses, the lawsuit alleges. Some charitable assets were used to pay the legal obligations of his businesses, promote hotels, purchase personal items or support his presidency, it claims.

The foundation's largest-ever donation, a gift to the Central Park Conservancy in 1989, also boosted the Trump family business, the Washington Post reports. The $264,000 gift paid for the restoration of a fountain that sat outside the Plaza Hotel, which Mr. Trump owned at the time.

Mr. 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, according to the suit, 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 portrait of Mr. Trump at a charity auction; and $5,000 for ads promoting Trump's hotels in the programs for charitable events.

Political uses

While it's illegal for charities to participate in political campaigns, the Trump Foundation was allegedly "co-opted" by Mr. Trump's presidential campaign, such as through supporting a 2016 Iowa charity fundraiser, according to the lawsuit. "In reality, the Fundraiser was a Trump Campaign event in which the Foundation participated," the lawsuit said.

The lawsuit also claims Mr. Trump gave a $25,000 to the campaign of Florida Attorney General Pam Bondi, using the foundation's funds, but failed to lawfully disclose the gift to the IRS.

Judge rejected Trump side's arguments

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.

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.

The Associated Press contributed to this report.