The U.S. Supreme Court cleared a New York grand jury to get U.S. President Donald Trump’s financial records while blocking for now House subpoenas that might have led to their public release before the election.

The cases were perhaps the most far-reaching of Trump’s presidency, testing his claim to broad protections from congressional and state criminal investigations while in the White House. The clashes forced Chief Justice John Roberts’s court to navigate politically polarizing and constitutionally weighty issues months before the presidential election.

Trump weighed in on Twitter about the rulings.

“The Supreme Court sends case back to Lower Court, arguments to continue,” he said. “Now I have to keep fighting in a politically corrupt New York. Not fair to this Presidency or Administration!”

In the House case, the court returned the fight to two federal appeals courts, saying they didn’t give close enough scrutiny to Trump’s contentions that the document demands would be too intrusive. Roberts said congressional subpoenas for presidential information “implicate special concerns regarding the separation of powers.”

Justices Clarence Thomas and Samuel Alito dissented, saying they would have gone further and rejected the House subpoenas altogether.

In grand jury case, the court rejected Trump’s call to give presidents complete immunity from criminal investigation while in office.

“The president is neither absolutely immune from state criminal subpoenas seeking his private papers nor entitled to a heightened standard of need,” Roberts wrote for the court. Thomas and Alito dissented in that case as well.

Trump’s two appointees, Justices Neil Gorsuch and Brett Kavanaugh, were in the majority in both cases.