Then-candidate Donald Trump presents an enlarged copy of a $100,000 contribution from the Donald J. Trump Foundation to Puppy Jake, a service dog charity for veterans, at a January 2016 campaign event in Davenport, Iowa. (Paul Sancya/AP)

A New York state judge on Friday denied a request by attorneys for President 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 D. Underwood in allowing the case to continue, saying it was fair for the attorney general to argue that the president used the Donald J. Trump Foundation to advance his campaign.

Attorney Alan Futerfas, who represents Trump and his three eldest children, had argued that the president 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 that 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.

Futerfas and a spokeswoman for the Trump Organization, the president’s company, did not immediately respond to requests for comment.

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

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

In asking that the case be thrown out, Futerfas made arguments last month including that the court lacked proper jurisdiction, that the attorney general’s office was biased against the president and that any mistakes made at the charity were too minor to merit such a case.

Trump’s attorneys also pointed out that the Trump Foundation, incorporated in 1987, had not written any checks to Trump’s campaign.

But Scarpulla sided with Underwood on that point, as well. In her ruling, Scarpulla wrote that the attorney general’s allegations that “Foundation checks were drawn up at Mr. Trump’s and the Campaign’s direction” were sufficient to support a claim that Trump “intentionally used foundation assets for his private interests knowing that it may not be in the Foundation’s best interest.”

Trump’s attorneys had also argued that because they found Underwood’s office to be operating out of political bias, they should be able to obtain documents and information from Underwood’s office.

But in dismissing the bias claim, Scarpulla shut the door on that possibility as well, calling the bias allegation and request for discovery both “irrelevant.”

Scarpulla noted that the outcome of this suit could hinge on an unrelated case pending in New York state: a lawsuit by former “Apprentice” contestant Summer Zervos, who alleges that Trump defamed her.

Trump has argued in both cases that, as a sitting president, he is immune from the claims — maintaining that the 1997 Supreme Court decision Clinton v. Jones, which said that presidents do not have immunity from civil litigation, does not apply in state courts.

If a New York appeals court agrees with the president in the Zervos case, Scarpulla wrote, “then I must dismiss the petition against Mr. Trump” in this case. The judge added that in that situation, Underwood might be able to continue her cases against Trump’s children Eric, Donald Jr. and Ivanka, who were directors of the Trump Foundation.

Underwood, who took office in May after Schneiderman resigned in the wake of allegations that he had physically abused several romantic partners, will be replaced in January by Letitia James, a Democrat who was elected to the post this month. She said during her campaign that she would continue the office’s inquiries into Trump.