The U.S. Court of Appeals for the Second Circuit on Monday granted President Donald Trump a last-minute reprieve in his effort to prevent New York prosecutors from obtaining his tax records.

The stay was issued not long after a federal judge rejected Trump’s claim that he was immune from criminal investigations in a bid to block a subpoena from the Manhattan district attorney seeking eight years of personal and business tax returns.

As a result of the stay, Mazars USA, the president's tax preparer, doesn't have to hand over the documents by 1 p.m. Monday, as was required. A panel of appellate judges will hear the case on an expedited basis and then issue a ruling.

Earlier Monday, U.S. District Court Judge Victor Marrero tossed the lawsuit Trump's legal team had brought against District Attorney Cyrus Vance arguing Vance should not receive Trump's tax returns because "'[v]irtually all legal commenters agree' that a sitting President of the United States is not 'subject to the criminal process' while he is in office.”

In a 75-page order, Marrero called the presidential immunity Trump invoked in the lawsuit to stop the production of tax documents "unqualified and boundless."

"As the court reads it, presidential immunity would stretch to cover every phase of criminal proceedings, including investigations, grand jury proceedings and subpoenas, indictment, prosecution, arrest, trial, conviction, and incarceration," Marrero wrote. "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 said he couldn't accept that legal view, "especially in the light of the fundamental concerns over excessive arrogation of power" that led the founding fathers to create a balance of power among the three branches of government.

In response to Trump asserting that not only he but also his family, businesses and associates were immune from producing documents, Marrero ruled that presidents, their families and businesses were not above the law.

Trump appeared to react to the judge's order on Twitter, writing: "The Radical Left Democrats have failed on all fronts, so now they are pushing local New York City and State Democrat prosecutors to go get President Trump."

"A thing like this has never happened to any President before," he said. "Not even close!"

Marrero's ruling amounted to an excoriation of Trump's position. In it, he wrote that "as articulated, such sweeping doctrine finds no support in the Constitution's text or history, or in germane guidance charted by rulings of the United States Supreme Court."

"The Court cannot square a vision of presidential immunity that would place the President above the law with the text of the Constitution, the historical record, the relevant case law, or even the DOJ Memos on which the President relies most heavily for support," Marrero wrote, adding that contrary "to the president's claims, the court’s conclusion today does not 'upend our constitutional design.' Rather, the court’s decision upholds it."

At another point in the ruling, Marrero invoked the Founding Fathers' repudiation of "the inviolability of the person of the King of England" and the "protective screen covering the Crown's actions from legal scrutiny," noting again that the Constitution conferred no such shield for a president.

A grand jury subpoena for the documents was issued by the Manhattan D.A.’s office to Mazars USA, which prepares the president’s tax returns, a little more than a month ago as part of a probe into the Trump Organization about payments made to two women who allegedly had affairs with the president.

Trump attorney Jay Sekulow said, "We are very pleased" by Second Circuit Court of Appeals' decision to issue a stay. The White House and Manhattan district attorney's office declined comment. Last week, the Justice Department joined Trump in his battle to block Vance's subpoena from being enforced.

While the Constitution does not provide explicit guidance on whether a president can charged with a crime while in office, a Justice Department Office of Legal Counsel memo states a president cannot be charged while in office. That memo has proven influential in past investigations involving Trump. However, that memo does not cover the act of merely investigating a sitting president. And Vance, who is a state official, is not bound by that guidance.

Vance is investigating payments made to two women, porn star Stormy Daniels and ex-Playboy model Karen McDougal, to silence their allegations of affairs with Trump prior to the 2016 presidential election. Trump has denied any affair with Daniels.

Trump's former attorney and fixer Michael Cohen is currently serving a three-year prison sentence for a litany of crimes that included facilitating those payments. In the case of Daniels, Cohen was reimbursed by Trump and his business for the illegal $130,000 expenditure he made to silence her.

The New York battle represents just one prong of Trump's multistate effort to keep his tax records private. In Washington, D.C., the president is currently suing to stop Congress from being able to access his state tax returns through a recently signed New York law. And his Treasury Department is currently fighting the House Ways and Means Committee to prevent the release of the president's tax information to that panel.

Meanwhile, a California judge last week temporarily blocked a new law aimed at forcing Trump to release his tax returns in order to appear on the ballot next fall.

While it is tradition for presidential candidates to release his or her tax returns, it is not required by law. Trump became the first major party nominee in four decades to withhold his tax information from the public when he sought office in 2016.

Trump has consistently cited an audit as the rationale for withholding his records. As president, his taxes come under audit annually. But this is not the only reasoning provided by the White House for why Trump has refused to make his tax information public. In April, then-White House press secretary Sarah Sanders claimed Democrats were not "smart enough" to read Trump's returns.