MANHATTAN (CN) — Hours before the Democratic presidential debates, a federal judge dismissed the Democratic National Committee’s lawsuit that accused the Trump campaign, the Russian Federation, WikiLeaks and others of interfering in the 2016 elections.

“The primary wrongdoer in this alleged criminal enterprise is undoubtably the Russian Federation, the first named defendant in the case and the entity that surreptitiously and illegally hacked into the DNC’s computers and thereafter disseminated the results of its theft,” wrote U.S. District Judge John Koeltl, a Clinton appointee.

Before weighing the evidence against Russia, however, Koeltl found that the Foreign Sovereign Immunities Act foreclosed him from holding it liable for the DNC server hack.

The DNC blamed a host of secondary actors in a conspiracy, including Russian-linked Maltese academic Joseph Mifsud; oligarchs Emin and Aras Agalarov; and Trump family members and campaign figures like Donald Trump Jr., Jared Kushner, Paul Manafort, Rick Gates, George Papadopoulos and Roger Stone.

Finding these claims likewise unconvincing, Koeltl ruled that the U.S. Constitution protected them from liability related to disseminating stolen emails.

“The First Amendment prevents such liability in the same way it would preclude liability for press outlets that publish materials of public interest despite defects in the way the materials were obtained so long as the disseminator did not participate in any wrongdoing in obtaining the materials in the first place,” the 81-page opinion states.

Citing precedent from the the Pentagon Papers case, Koeltl held that treating WikiLeaks as an accomplice “would render any journalist who publishes an article based on stolen information a co-conspirator in the theft.”

“If WikiLeaks could be held liable for publishing documents concerning the DNC’s political financial and voter-engagement strategies simply because the DNC labels them ‘secret’ and trade secrets, then so could any newspaper or other media outlet,” the opinion states. “But that would impermissibly elevate a purely private privacy interest to override the First Amendment interest in the publication of matters of the highest public concern. The DNC’s published internal communications allowed the American electorate to look behind the curtain of one of the two major political parties in the United States during a presidential election. This type of information is plainly of the type entitled to the strongest protection that the First Amendment offers.”

WikiLeaks and its founder Julian Assange argued last year that the DNC’s lawsuit threatened freedom of the press. Columbia University’s Knight First Amendment Institute, Reporters Committee for Freedom of the Press, and the American Civil Liberties Union echoed those concerns in a friend-of-the-court brief.

Joshua Dratel, an attorney for WikiLeaks, applauded Koetl’s ruling.

“It reaffirms some important First Amendment principles that apply to journalism across the board, regardless of whether you’re a powerful institution or a small independent operation,” Dratel said in a phone interview.

Attorneys for the Trump campaign, Kushner, Manafort and Stone did not immediately respond to requests for comment.

Trump himself meanwhile quickly celebrated the decision on Twitter.

“The judge said the DNC case was ‘entirely divorced’ from the facts, yet another total & complete vindication & exoneration from the Russian, WikiLeaks and every other form of HOAX perpetrated by the DNC, Radical Democrats and others,” the president tweeted.

It is a point in fact, however, that Judge Koeltl dismissed the DNC’s lawsuit on legal rather than factual grounds. Indeed, motions to dismiss do not turn on the merits but rather whether the allegations plausibly state a violation of the law.

DNC spokeswoman Adrienne Watson warned that permitting such conduct as a rule would have dire consequences for cyber- and election security.

“At first glance, this opinion raises serious concerns about our protections from foreign election interference and the theft of private property to advance the interests of our enemies,” Watson said in a statement. “At a time when the Trump administration and Republican leaders in Congress are ignoring warnings from the president’s own intelligence officials about foreign interference in the 2020 election, this should be of concern to anyone who cares about our democracy and the sanctity of our elections.”

The Agalarov family, whose entanglements in Trump’s Miss Universe pageant and the Trump Tower meeting took focus in the lawsuit, expressed a desire to put the lawsuit behind them.

“The Agalarovs are pleased with the court’s decision and hopeful that it will bring an end to this saga,” their attorney Scott Balber said in an email.

Judge Koeltl dismissed the lawsuit without leave to refile. DNC spokeswoman Adrienne Watson and its attorney Joseph Sellers did not immediately respond to requests for comment on whether they would pursue an appeal.

Papadopolous’ attorney Caroline Polisi reiterated her position from oral arguments that the allegations against her client were “anemic and bordered on the absurd.”

“As we argued in our motions to dismiss and oral argument, the DNC’s case was nothing more than an attempt to rewrite history, in the face of incontrovertible evidence to the contrary,” Polisi said in an email.

The Trump campaign sought to sanction the DNC for continuing to pursue the lawsuit after special counsel Robert Mueller did not establish a criminal conspiracy with Russia. The Democrats noted that civil liability is a lower standard, and Mueller documented copious ties between the Trump campaign and Russia.

Declining to wade into that controversy, Koeltl rejected sanctions and did not consider the Mueller report in his ruling.