A New York state judge on Friday denied a request by attorneys for President Donald Trump to throw out a lawsuit alleging that Trump and his family violated charity laws with the management of their personal foundation.

Justice Saliann Scarpulla sided with New York Attorney General Barbara Underwood in allowing the case to continue, saying it was fair for the attorney general to argue that Trump used the Donald Trump Foundation to advance his presidential campaign.

Trump attorney Alan Futerfas, who represents Trump and his three eldest children, had argued that Trump was acting in his individual capacity — not on behalf of the foundation — in hosting a televised fundraiser for veterans and allowing his campaign staff to dictate what groups received donations.

But the allegations, Scarpulla wrote in her decision, “show that Mr. Trump was acting in both of his capacities as campaign candidate and president of the Foundation.”

She wrote that Underwood “adequately alleges that the political acts by Mr. Trump and the Campaign are attributable to the Foundation.”

In a statement Friday, Underwood applauded the decision, saying the “Trump Foundation functioned as little more than a checkbook to serve Mr. Trump’s business and political interests.”

In the past, Trump has called the suit politically motivated and “ridiculous,” criticizing Underwood and her predecessor, Eric Schneiderman, a Democrat.

New York state officials began scrutinizing the Trump Foundation in response to a Washington Post investigation.

Underwood brought the suit in June, arguing that Trump and three of his children, Donald Jr., Ivanka and Eric Trump, had repeatedly misused the nonprofit to pay off his businesses’ creditors, to decorate one of his golf clubs and to stage a multimillion-dollar giveaway at 2016 campaign events.

In asking for the case to be thrown out, Futerfas argued last month that the court lacked proper jurisdiction, that the Attorney General’s Office was biased against the president and that any mistakes made at his charity were too minor to merit such a case, among other reasons.