A New York-based appeals court granted temporary relief to President Donald Trump Monday after a federal judge judge ruled he and his accountant must hand over years of tax return information.

The decision put a freeze on a lower court judge's decision to require immediate compliance with a subpoena that would have put reams of financial information into the hands of prosecutors.

A federal judge in New York earlier Monday ruled a Trump accounting firm must turn over eight years of tax returns and comply with a subpoena in the latest legal turn that could ultimately provide information about the president's finances.

The judge also said that Trump is not immune from prosecution while in office - something the president's lawyers had made the center of their case and which will now be at the heart of the appeal.

Soon after the judge issued his blistering opinion, lawyers for the president filed an emergency motion to appeal the decision, and the Second Circuit Court of Appeals granted it later Monday. The accounting firm was facing a Monday afternoon deadline to turn over tax returns that were the subject of a grand jury subpoena.

Manhattan District Attorney Cy Vance's office is seeking the information as part of an investigation that was revealed after longtime Trump lawyer Michael Cohen pleaded guilty to facilitating payments to porn star Stormy Daniels, who claims she had an affair with Trump, shortly before Election Day in 2016.

FILE - In this Oct. 4, 2019, file photo, President Donald Trump talks to reporters on the South Lawn of the White House, in Washington. The nation's business economists think President Trump's trade war with China will contribute to a sharp slowdown in economic growth this year and next, raising concerns about a possible recession starting late next year. (AP Photo/Evan Vucci, File)

A judicial panel will hear the case on an expedited basis.

In crafting his ruling, District Court Judge Victor Marrero turned aside the argument put forward by Trump's lawyers that he is immune from prosecution while serving as president.

The Manhattan District Attorney's office had subpoenaed the returns, both Trump's personal returns and those from the Trump Organization as part of its wide-ranging investigation.

Scroll down for the federal judge's ruling

Judge Marrero blasted the sweeping arguments put forward by Trump's personal attorneys that as a sitting president, Trump should not have to face the same investigatory tactics as ordinary citizens.

'This Court cannot endorse such a categorical and limitless assertion of presidential immunity from judicial process,' the Bill Clinton nominee wrote in his ruling.

He blasted a 'virtually limitless' shield from prosecution that Trump's private attorneys are seeking to enforce – and even invoked impeachment, writing that: 'Until the President leaves office by expiration of his term, resignation, or removal through impeachment and conviction, his exemption from criminal proceedings would extend not only to matters arising from performance of the President's duties and functions in his official capacity, but also to ones arising from his private affairs, financial transactions, and all other conduct undertaken by him as an ordinary citizen, both during and before his tenure in office.'

The judge chided Trump's lawyers for asserting an 'extraordinary claim' by arguing that presidents are 'immune' from the wheels of justice while they are in office and argued this would give the president 'virtually limitless' power to ignore the U.S. Constitution.

'That constitutional protection presumably would encompass any conduct, at any time, in any forum, whether federal or state, and whether the President acted alone or in concert with other individuals,' the judge wrote.

Trump's lawyers immediately filed an emergency appeal Monday.

Counsel to the president Jay Sekulow provided only a brief statement when asked about the ruling. 'We are very pleased that the U.S. Court of Appeals for the Second Circuit has issued a stay of the subpoena issued by New York County District Attorney Cy Vance,' he said in a statement.

Cyrus Vance Jr., Manhattan New York district attorney, has subpoenaed eight years of Trump tax returns

Longtime Trump lawyer Michael Cohen is serving a three-year prison sentence. The DA is probing whether Trump contributed any campaign violations related to the payoffs to porn star Stormy Daniels and former Playboy model Karen McDougal

Trump accused 'Radical Left Democrats' of pushing the investigation

New York prosecutors are also examining the $150,000 payment that American Media Inc. made to former Playboy model Karen McDougal

The judge further argued that the theory of Trump's lawyers would extend derivatively to immunize misconduct of 'any other person, business affiliate, associate, or relative' who may have collaborated in committing 'unlawful acts.'

DA Cy Vance's office obtained a grand jury subpoena for Mazars USA, Trump's longtime accounting firm, seeking the information, and the firm has acknowledged in court it has return information in its possession.

Vance's office is probing the Stormy Daniels payoffs and whether they constituted a campaign finance violation that could implicate the president.

The DA is also probing payments that American Media Inc. made to Playboy model Karen McDougal during the 2016 campaign. Both women claimed they had affairs with Trump, which he denies.

Longtime Trump lawyer Michael Cohen is serving a three-year prison sentence in New York in part due to a campaign finance violation he testified was 'directed' by Trump

Vance subpoenaed the tax records from the president's accounting firm Mazars USA on August 29.

Judge Victor Marrero ruled that a subpoena issued by the Manhattan DA must be enforced

Under Trump's claim, he would be protected from any criminal proceeding until he leaves office or is removed 'through impeachment and conviction,' the judge argued

Blasts from federal judge overseeing Trump taxes case in New York On Trump immunity: 'This Court cannot endorse such a categorical and limitless assertion of presidential immunity from judicial process.' On extent of his 'shield' from prosecution and impeachment: 'According to this categorical doctrine as presented in this proceeding, the constitutional dimensions of this presidential shield from judicial process are virtually limitless: Until the President leaves office by expiration of his term, resignation, or removal through impeachment and conviction, his exemption from criminal proceedings would extend not only to matters arising from performance of the President's duties and functions in his official capacity, but also to ones arising from his private affairs, financial transactions, and all other conduct undertaken by him as an ordinary citizen, both during and before his tenure in office.' On range of jurisdictions where the president would be protected: 'That constitutional protection presumably would encompass any conduct, at any time, in any forum, whether federal or state, and whether the President acted alone or in concert with other individuals.' On ways being subject to legal proceedings could interfere with key tasks: 'The Court recognizes that subjecting the President to some aspects of criminal proceedings could impermissibly interfere with or even incapacitate the President's ability to discharge constitutional functions. Certainly lengthy imprisonment upon conviction would produce that result.' On Founders' disdain for monarch-like protection 'Shunning the concept of the inviolability of the person of the King of England and the bounds of the monarch's protective screen covering the Crown's actions from legal scrutiny, the Founders disclaimed any notion that the Constitution generally conferred similarly all-encompassing immunity upon the President.' On Justice Department memos stating the president cannot be indicted while in office: 'The theory has gained a certain amount of axiomatic acceptance, and the DOJ Memos which propagate it have assumed substantial legal force as if their conclusion were inscribed on constitutional tablets so-etched by the Supreme Court. The Court considers such popular currency for the categorical concept and its legal support as not warranted.' Advertisement

But Justice Department lawyers asked the judge to press pause on the proceedings so 'weighty constitutional issues' could be decided. Marrero quickly decided them.

Trump also asked Marrero to oversee the case, removing it from the state court where a grand jury green-lighted Vance's subpoena.

He has broken the recent tradition of releasing his tax returns, claiming for years that they are under a lengthy IRS audit.

The House Ways and Means of Committee has been trying to obtain Trump's tax returns on a separate track, under a law that allows the heads of tax-writing committees to obtain return information. The Treasury Department, however, has resisted turning over the information.

Following subpoenas of both the Trump Organization and Mazars, Trump's lawyers filed an injunction seeking the judge to stop the subpoenas.

In a technical note that could play out during the appeals process, the judge wrote that 'the Court is not certain that attorneys privately retained by the person who is President can bring suit on behalf of the United States' and that the Justice Department has filed a 'Statement of Interest' rather than formally intervening or stating is appearing 'on behalf of the President in connection with official presidential business implicating United States interests.

The president's lawyers argued that the District Attorney may not be acting in good faith – and noted that it matches subpoenas issued by the Democratic-run Ways and Means Committee.

The judge also cited internal Justice Department memos that state that a president cannot be indicted while in office. Those members were a key feature of former Special Counsel Robert Mueller's legal reasoning. He decided in his report not to decide whether or not the president obstructed justice.

The judge writes that the theory has 'gained a certain amount of axiomatic acceptance' as if it were inscribed on 'constitutional tablets so-etched by the Supreme Court.'

But the court considers such 'popular currency' and the legal support that founds it to be 'not warranted.'

If a president invokes his claimed 'absolute immunity' in a case involving other people, it could potentially allow the 'guilty to go free.'