A Pennsylvania state judge ruled that President Donald Trump is protected by presidential immunity for the statements he made creating doubt about the 2020 election results while in office.

Philadelphia County Court of Common Pleas Judge Michael Erdos ruled Monday that 2020 election worker James Savage is unable to sue Trump over the claims, according to The Hill.

Trump’s immunity includes a tweet and other comments he made from the White House while a Pennsylvania state Senate committee met in November 2022, the judge also said.

“Other legal proceedings may examine the propriety of his statements and actions while he was the President and whether, as the plaintiffs in this and other cases contend, it was this conduct which served as the actual threat to our democracy,” Erdos wrote in his ruling. “But this case is not the proper place to do so. Here, Trump is entitled to Presidential immunity.”

Savage, a Pennsylvania voting machine supervisor, filed two lawsuits, which were later consolidated, alleging that Trump, attorney Rudy Giuliani, two poll watchers and others conspired to defame him. Savage alleged Trump damaged his reputation by falsely claiming he altered the 2020 election result, which led to him receiving death threats and having two heart attacks.

Trump is not totally in the clear. Erdos ruled that Savage’s third defamation claim, related to remarks after Trump left the White House, is not protected by immunity, so the case survived Trump’s motion to dismiss, according to Bloomberg.

“Today, the Court made it clear that it is well within the President’s discretion to address the integrity of our election without fear of liability,” Trump legal spokeswoman Alina Habba said. “We expect that the rest of Mr. Savage’s claims will similarly be disposed of as they are without merit.”

Regardless, the ruling is a win for Trump, who has argued that he should be protected by presidential immunity in everything from Jan. 6 lawsuits to a defamation case brought by author E. Jean Carroll. A jury found Trump liable for battery and defamation in a case brought by Carroll in May.