The president has gone to great lengths to shield his tax returns and other financial records from public scrutiny.
The Supreme Court ruled Thursday that President Trump cannot block the release of his financial records to prosecutors in New York, a major defeat for Mr. Trump, but a decision that probably means the records will continue to be shielded from public scrutiny until after the election and perhaps indefinitely.
The vote was 7 to 2.
The court is expected to rule shortly on separate subpoenas from Congress.
Mr. Trump had asked the court to block both sets of subpoenas. They sought information from Mr. Trump’s accountants and bankers, not from Mr. Trump himself, and the firms have indicated that they would comply with the court’s ruling.
Mr. Trump’s lawyers had argued that he was immune from all criminal proceedings and investigations so long as he remained in office and that Congress was powerless to obtain his records because it had no legislative need for them.
House Democrats and New York prosecutors said the records may shed light on Mr. Trump’s foreign entanglements, possible conflicts of interest, whether he has paid his taxes and whether his hush money payments violated campaign finance laws.
The court’s decision was a major statement on the scope and limits of presidential power, one that will take its place with landmark rulings that required President Richard M. Nixon to turn over tapes of Oval Office conversations and forced President Bill Clinton to provide evidence in a sexual harassment suit.
One of the cases concerned a subpoena to Mr. Trump’s accounting firm, Mazars USA, from the office of the Manhattan district attorney, Cyrus R. Vance Jr., a Democrat. It sought eight years of business and personal tax records in connection with an investigation of the role that Mr. Trump and the Trump Organization played in hush-money payments made in the run-up to the 2016 election.
Both Mr. Trump and his company reimbursed the president’s former lawyer and fixer, Michael D. Cohen, for payments made to the pornographic film actress Stormy Daniels, who claimed that she had an affair with Mr. Trump.
Mr. Cohen was also involved in payments to Karen McDougal, a Playboy model who had also claimed she had a relationship with Mr. Trump. The president has denied the relationships.
Mr. Trump sued to stop the accounting firm from turning over the records, but lower courts ruled against him. In a unanimous ruling, the United States Court of Appeals for the Second Circuit, in New York, said state prosecutors may require third parties to turn over a sitting president’s financial records for use in a grand jury investigation.
In a footnote to the decision, Chief Judge Robert A. Katzmann, wrote that the information sought was in a sense unexceptional.
“We note that the past six presidents, dating back to President Carter, all voluntarily released their tax returns to the public,” Judge Katzmann wrote. “While we do not place dispositive weight on this fact, it reinforces our conclusion that the disclosure of personal financial information, standing alone, is unlikely to impair the president in performing the duties of his office.”
Mr. Trump’s lawyers argued that he was immune from all criminal proceedings and investigations so long as he remained in office.
The Justice Department filed briefs supporting Mr. Trump but took a more measured position, saying that prosecutors should be forced to meet a demanding standard before they were allowed to obtain the information they sought.
Lawyers for Mr. Vance responded that the Supreme Court had already decided the central issue in the case in 1974 in United States v. Nixon, which required President Richard M. Nixon to disclose tapes of Oval Office conversations in response to a subpoena in a criminal case.
The second subpoena, also directed to the accounting firm, came from the House Oversight and Reform Committee, which is investigating the hush-money payments and whether Mr. Trump inflated and deflated descriptions of his assets on financial statements to obtain loans and reduce his taxes.
Mr. Trump’s lawyers argued that the committee was powerless to obtain his records because it had no legislative need for them. They said the panel was engaged in an improper criminal inquiry and was not seeking information to help it enact legislation.
Lawyers for the committee responded that they had a legitimate need for the information to fulfill their legislative and oversight responsibilities.
A divided three-judge panel of the United States Court of Appeals for the District of Columbia Circuit refused to block the subpoena.
The third set of subpoenas came from the House Financial Services and Intelligence Committees and were addressed to two financial institutions that did business with Mr. Trump, Deutsche Bank, and Capital One. They sought an array of financial records related to the president, his companies and his family.
A different three-judge panel of the Second Circuit ordered most of the requested materials to be disclosed. It made an exception for sensitive personal information unrelated to the committee’s investigations.
“The committees’ interests in pursuing their constitutional legislative function is a far more significant public interest than whatever public interest inheres in avoiding the risk of a chief executive’s distraction arising from disclosure of documents reflecting his private financial transactions,” Judge Jon O. Newman wrote for the majority.
The cases tested the independence of the Supreme Court, which is dominated by Republican appointees, including two named by Mr. Trump. In earlier Supreme Court cases in which presidents sought to avoid providing evidence, the rulings did not break along partisan lines.
To the contrary, the court was unanimous in ruling against Presidents Nixon and Bill Clinton in such cases, with Nixon and Clinton appointees voting against the presidents who had placed them on the court. The Nixon case led to his resignation in the face of mounting calls for his impeachment. The Clinton case led to Mr. Clinton’s impeachment, though he survived a Senate vote on his removal.