New York’s attorney general on Thursday filed a lawsuit against President Trump, alleging he illegally used money from his charitable foundation to pay off his creditors, decorate one of his golf clubs and help his presidential campaign.

The Donald J. Trump Foundation “was little more than a checkbook” for the commander in chief and engaged in “improper and extensive political activity” and “repeated and willful self-dealing transactions,” charges Democratic AG Barbara Underwood, who’s suing to dissolve the charity and secure $2.8 million in restitution.

The foundation “is little more than an empty shell that functions with no oversight by its board of directors,” which hasn’t met since 1999 — and in its absence, “Trump ran the Foundation according to his whim, rather than the law,” the suit alleges.

Trump’s children Donald Trump Jr., Ivanka Trump and Eric Trump are also named in the suit, because they have been longtime board members of the foundation.

Underwood alleges that the foundation allowed itself to be “co-opted” by Trump’s 2016 election campaign — raising money to be handed out at campaign events “to advance his political goals.”

The two worked hand-in-hand to stage a televised “Trump for Vets” event in Iowa a week before the state’s caucuses — bringing in $5.6 million of tax-free donations, $2.83 million of which went into the foundation’s coffers while the rest went straight to charitable groups, according to the suit.

Campaign manager Corey Lewandowski took control of the cash, dictating which veterans groups would get the cash. Trump then handed out giant novelty checks to the recipients at rallies — with both the foundation’s name and “Make America Great Again” printed on them, the suit charges.

“The foundation’s grants made Mr. Trump and the campaign look charitable and increased the candidate’s profile to Republican primary voters and among important constituent groups,” the suit says.

But the foundation’s dodgy dealings pre-date the campaign, Underwood charges.

Trump hasn’t made any contributions into the foundation himself since 2008, instead relying on donations from others, according to the suit.

In 2014, the future president made a winning $10,000 bid on a painting of himself at a charity auction — then used the foundation’s cash to foot the bill. The painting was used to decorate the Trump National Doral Golf Club in Miami.

And in 2012, he used the foundation to raise money for — and then pay off — a lawsuit settlement with a Wall Street bigwig, the suit claims.

Commodities trading executive Martin Greenberg won a $1 million contest to score a hole-in-one at the 13th hole at the Trump National Golf Course, but the competition’s insurer refused to pay, claiming he didn’t hit the ball from the correct distance.

When Greenberg sued the course and scored a $158,000 settlement, Trump’s foundation held an auction for a lifetime membership to his golf courses to raise the cash.

A contract between the auction site managing the bids and the foundation — signed by Trump’s attorney Michael Cohen — falsely claimed the money was going to the charity rather than to pay off the suit.

In the suit, Underwood notes that the president had already paid more than $330,000 in reimbursements and penalty taxes since 2016.

New York state began investigating the Trump Foundation in response to a 2016 probe by The Washington Post.

In late 2016, Trump promised to shut down the Trump Foundation, but could not while the attorney general’s probe continued.

A foundation spokesman on Thursday slammed the lawsuit as “politics at its very worst.”

“The Foundation has donated over $19 million to worthy charitable causes – more than it even received. The President himself – or through his companies – has contributed more than $8 million,” it said in a statement.

“The Foundation currently has $1.7 million remaining which the NYAG has been holding hostage for political gain. This is unconscionable – particularly because the Foundation previously announced its intention to dissolve more than a year and a half ago.”

Underwood — who was only recently promoted to the position of attorney general after Eric Schneiderman resigned amid allegations that he had physically abused several romantic partners — is also asking asked that Trump be banned from leading any other state nonprofit for 10 years.

She notes that the president had already paid more than $330,000 in reimbursements and penalty taxes since 2016.