President Donald Trump's longtime accounting firm must hand over eight years of his tax returns to New York prosecutors, a U.S. appeals court ruled Monday in the latest setback for Trump in his tenacious efforts to keep his finances secret.

The ruling by the New York-based 2nd U.S. Circuit Court of Appeals backed the ability of prosecutors to enforce a subpoena for the returns against accounting firm Mazars LLP.

The three-judge panel, consisting of three Bill Clinton appointees, issued its ruling in a blistering opinion where they took on the president's claim of immunity, reached back to the founding of the republic to find times when presidents cooperated in the legal process, and noted that the last six presidents released their own tax returns voluntarily even as Trump invoked a privilege to keep them private.

A footnote in the opinion says: 'We note that the past six presidents, dating back to President Carter, all voluntarily released their tax returns to the public.

'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.'

With the Republican president set to appeal, the ruling sets the stage for an expected showdown at the U.S. Supreme Court, whose 5-4 conservative majority includes two justices appointed by Trump.

Trump's lawyer told the three-judge appeals panel this month that Trump is immune from state criminal law even if he shoots someone because he's president.

Manhattan District Attorney Cyrus R. Vance Jr. sought the records in a broader probe that includes payments made to buy the silence of two women who claim they had affairs with the president before the 2016 presidential election. One of them was Stormy Daniels

Said Trump attorney Jay Sekulow: 'The decision of the Second Circuit will be taken to the Supreme Court. The issue raised in this case go to the heart of our Republic. The constitutional issues are significant.'

The judges took on the president's claim of immunity, and said a subpoena to his longtime accounting firm would in no way disrupt his ability to carry out his duties.

'But we are not faced, in this case, with the President’s arrest or imprisonment, or with an order compelling him to attend court at a particular time or place, or, indeed, with an order that compels the President himself to do anything,' the judges wrote. 'The subpoena at issue is directed not to the President, but to his accountants; compliance does not require the President to do anything at all.'

'We find no support in the Nixon Court’s conclusion—that even documents exposing the President’s confidential, official conversations may properly be obtained by subpoena—for the proposition that a President’s private and non‐privileged documents may be absolutely shielded from judicial scrutiny,' they wrote.

They went back to the early days of the republic to show that presidents are not immune from the judicial process.

'Over 200 years ago, Chief Justice Marshall, sitting as the trial judge in the prosecution of Aaron Burr, upheld the issuance of a subpoena duces tecum to President Jefferson,' they wrote, in reference to an order for a person bring something with them to court.

Manhattan District Attorney Cyrus R. Vance Jr. sought the records in a broader probe that includes payments made to buy the silence of two women who claim they had affairs with the president before the 2016 presidential election.

Trump's lawyer told the three-judge appeals panel this month that Trump is immune from state criminal law even if he shoots someone because he's president.

At the time, Trump attorney William Consovoy faced skeptical questions from the judicial panel, and was asked a variation of Trump's famous boast he could shoot someone on Fifth Ave. and not lose any support.

'What’s your view on the 5th avenue example?' Judge Denny Chin asked him. 'Local authorities couldn’t investigate, they couldn’t do anything about it?'

Consovoy responded: 'Once a president is removed from office, any local authority – this is not a permanent immunity,' Consovoy responded, making the point that the 73-year-old president could face prosecution at the end of his term.

'Well I’m talking about while in office,' the judge pressed. 'That's the [hypothetical question].

'No,' Consovoy responded.

'Nothing could be done. That’s your position?' Judge Chin followed up.

'That is correct,' Consovoy replied, in an exchange that can be heard on audio.

'Even gathering documents that could be used later? Once the president leaves office, that can’t be done either?' the judge wanted to know.

Then Consovoy hedged: 'That can be done, I apologize. I meant to say with respect to the president, directly or through his custodians. This grand jury is proceeding. We have not sought to enjoin the entirety for the grand jury,' he said, in reference to the DA's probe of potential campaign finance or other violations.

The Appeals Court found the president 'has not shown a likelihood of success on the merits of his claims sufficient to warrant injunctive relief.'

Trump said in 2016: 'I could stand in the middle of Fifth Avenue and shoot somebody and I wouldn’t lose any voters.'

Vance had already reached an agreement not to enforce a subpoena until after the Appeals Court ruling, to allow for a quick appeal to the Supreme Court.