WASHINGTON (AP) — The Supreme Court on Monday ruled for the first time that former presidents have some immunity from prosecution, extending the delay in the Washington criminal case against Donald Trump on charges he plotted to overturn his 2020 presidential election loss and all but ending prospects the former president could be tried before the November election.

In a historic 6-3 ruling, the justices returned Trump’s case to the trial court to determine what is left of special counsel Jack Smith’s indictment of Trump. The outcome means additional delay before Trump could face trial.

The court’s decision in a second major Trump case this term, along with its ruling rejecting efforts to bar him from the ballot because of his actions following the 2020 election, underscores the direct and possibly uncomfortable role the justices are playing in the November election.

“Under our constitutional structure of separated powers, the nature of presidential power entitles a former president to absolute immunity from criminal prosecution for actions within his conclusive and preclusive constitutional authority,” Chief Justice John Roberts wrote for the court. “And he is entitled to at least presumptive immunity from prosecution for all his official acts. There is no immunity for unofficial acts.”

Roberts was joined by the other five conservative justices. The three liberal justices dissented.

“Today’s decision to grant former presidents criminal immunity reshapes the institution of the presidency. It makes a mockery of the principle, foundational to our Constitution and system of government, that no man is above the law,” Justice Sonia Sotomayor wrote in a scathing dissent.

Sotomayor, who read a summary of her dissent aloud in the courtroom, said the protection afforded presidents by the court “is just as bad as it sounds, and it is baseless.”

Trump posted on his social media network shortly after the decision was released: “BIG WIN FOR OUR CONSTITUTION AND DEMOCRACY. PROUD TO BE AN AMERICAN!”

Smith’s office declined to comment on the ruling.

The justices knocked out one aspect of the indictment. The opinion found Trump is “absolutely immune” from prosecution for alleged conduct involving discussions with the Justice Department.

Trump is also “at least presumptively immune” from allegations that he tried to pressure Vice President Mike Pence to reject certification of Democrat Joe Biden’s electoral vote win on Jan. 6, 2021. Prosecutors can try to make the case that Trump’s pressure on Pence still can be part of the case against him, Roberts wrote.

The ruling was the last of the term and it came more than two months after the court heard arguments, far slower than in other epic high court cases involving the presidency, including the Watergate tapes case.

The Republican former president has denied doing anything wrong and has said this prosecution and three others are politically motivated to try to keep him from returning to the White House.

In May, Trump became the first former president to be convicted of a felony, in a New York court. He was found guilty of falsifying business records to cover up a hush money payment made during the 2016 presidential election to a porn actor who says she had sex with him, which he denies. He still faces three other indictments.

Smith is leading the two federal probes of the former president, both of which have led to criminal charges. The Washington case focuses on Trump’s alleged efforts to overturn the 2020 election after he lost to Biden. The case in Florida revolves around the mishandling of classified documents. The other case, in Georgia, also turns on Trump’s actions after his defeat in 2020.

If Trump’s Washington trial does not take place before the 2024 election and he is not given another four years in the White House, he presumably would stand trial soon thereafter.

But if he wins, he could appoint an attorney general who would seek the dismissal of this case and the other federal prosecution he faces. He could also attempt to pardon himself if he reclaims the White House. He could not pardon himself for the conviction in state court in New York.

The Supreme Court that heard the case included three justices appointed by Trump — Amy Coney Barrett, Neil Gorsuch and Brett Kavanaugh — and two justices who opted not to step aside after questions were raised about their impartiality.

Justice Clarence Thomas’ wife, Ginni, attended the rally near the White House where Trump spoke on Jan. 6, 2021, though she did not go the Capitol when a mob of Trump supporters attacked it soon after. Following the 2020 election, she called it a “heist” and exchanged messages with then-White House chief of staff Mark Meadows, urging him to stand firm with Trump as he falsely claimed that there was widespread election fraud.

Justice Samuel Alito said there was no reason for him to step aside from the cases following reports by The New York Times that flags similar to those carried by the Jan. 6 rioters flew above his homes in Virginia and on the New Jersey shore. His wife, Martha-Ann Alito, was responsible for flying both the inverted American flag in January 2021 and the “Appeal to Heaven” banner in the summer of 2023, he said in letters to Democratic lawmakers responding to their recusal demands.

Trump’s trial had been scheduled to begin March 4, but that was before he sought court-sanctioned delays and a full review of the issue by the nation’s highest court.

Before the Supreme Court got involved, a trial judge and a three-judge appellate panel had ruled unanimously that Trump can be prosecuted for actions undertaken while in the White House and in the run-up to Jan. 6.

“For the purpose of this criminal case, former President Trump has become citizen Trump, with all of the defenses of any other criminal defendant,” the appeals court wrote in February. “But any executive immunity that may have protected him while he served as President no longer protects him against this prosecution.”

U.S. District Judge Tanya Chutkan, who would preside over the trial in Washington, ruled against Trump’s immunity claim in December. In her ruling, Chutkan said the office of the president “does not confer a lifelong ‘get-out-of-jail-free’ pass.”

“Former Presidents enjoy no special conditions on their federal criminal liability,” Chutkan wrote. “Defendant may be subject to federal investigation, indictment, prosecution, conviction, and punishment for any criminal acts undertaken while in office.”