Washington (CNN) President Donald Trump lost an appeal Monday to keep his tax returns from a Manhattan grand jury, setting up a potential Supreme Court challenge.

A three-judge panel for the Second Circuit Court of Appeals said "presidential immunity does not bar a state grand jury from issuing a subpoena in aid of its investigation of potential crimes committed by persons within its jurisdiction, even if that investigation may in some way implicate the president."

The court also noted that "the only question before us is whether a state may lawfully demand production by a third party of the President's personal financial records for use in a grand jury investigation while the President is in office." The judges added that "we hold that any presidential immunity from state criminal process does not bar the enforcement of a subpoena."

Trump sued the Manhattan District Attorney's office to block a subpoena it sent to his long time accounting firm Mazars USA seeking eight years of tax returns. Attorneys for Trump argued a President is immune from criminal investigations, a claim the district judge dismissed. Trump then appealed that decision.

The appeals court ruling gives a green light, in theory, for investigators to obtain the President's tax returns, but Trump's attorney Jay Sekulow said the President will continue his appeal.

"The decision of the Second Circuit will be taken to the Supreme Court," Sekulow said in a statement. "The issue raised in this case goes to the heart of our Republic. The constitutional issues are significant."

Trump's lawyers have 10 days to appeal to the Supreme Court under an agreement it previously reached with Manhattan District Attorney Cy Vance's office. Under the deal, Vance's office would not move to enforce the subpoena so long as Trump's lawyers agree to appeal to the Supreme Court in the current term.

The district attorney's office also agreed not to enforce the subpoena until the Supreme Court either declines to hear the case or reaches a decision, whichever comes first. Should Vance prevail and ultimately obtain Trump's tax returns they would not be publicly released under grand jury secrecy rules. The only likely way the returns would become public would be in a trial or court proceeding.

Vance's office declined to comment Monday on the panel's decision.

The appeals court ruling affirmed the decisions by US District Judge Victor Marrero who dismissed Trump's "extraordinary" claim that any occupant of the White House enjoys "absolute immunity from criminal process of any kind." Marrero said in a 75-page opinion that such a position "would constitute an overreach of executive power."

The judge described Trump's assertion of immunity as "repugnant to the nation's governmental structure and constitutional values."

Trump has broken previous presidential precedent by refusing to release his tax returns.

This story has been updated.