Donald Trump presents a check to members of Support Siouxland Soldiers during a rally, in Iowa, January 31, 2016 (Patrick Semansky/AP)

The Trump Foundation will shut down after a series of revelation about diversion of charity funds and a lawsuit over its “shocking pattern of illegality”.

New York State Attorney General Barbara Underwood said the Trump Foundation had signed a stipulation for its dissolution under judicial supervision. Remaining funds must be distributed to charitable causes, chosen by Trump and his children Ivanka, Donald Jr. and Eric and approved by Underwood.

Last month, a court decision allowed the Attorney General’s lawsuit to proceed. Underwood said on Tuesday:

Our petition detailed 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. This amounted to the Trump Foundation functioning as little more than a checkbook to serve Mr Trump’s business and political interests.

The lawsuit said the Foundation had provided up to $3 million to Trump’s 2016 Presidential campaign. The candidate received more than $2 million at a fundraiser in Iowa for the Foundation, but Trump’s campaign manager Corey Lewandowski determined when and where money would be distributed.

At least five $100,000 grants were made to Iowa groups in the days before the February 2016 Republican caucuses.

Other disbursements benefitted Trump personally. The Foundation’s largest donation of $264,321 was for construction of a fountain outside Trump Tower. It spent $10,000 on a giant painting of Trump. The smallest disbursement was for $7 to the Boy Scouts — in 1999, the same year that Donald Trump Jr. joined the Scouts with an enrollment fee of $7.