A federal judge ordered President Donald Trump to turn over eight years of his tax returns to New York state prosecutors.

The Manhattan district attorney's office subpoenaed Trump's accounting firm, Mazars USA, for his personal and corporate returns going back to 2011.

Trump's legal team tried to block the subpoena by asserting that as a sitting president, he is immune to criminal investigation.

US District Judge Victor Marrero wrote in his ruling that the president's argument made an "extraordinary" reach and was "repugnant to the nation's governmental structure and constitutional values."

Visit Business Insider's homepage for more stories.

A federal judge on Monday ordered President Donald Trump to turn over eight years of his tax returns to New York state prosecutors.

The decision came after the Manhattan district attorney's office subpoenaed Trump's accounting firm, Mazars USA, for his personal and corporate taxes going back to 2011.

Trump's legal team, in turn, sought to block the subpoena by arguing that a sitting president is immune from criminal investigation. The Justice Department joined Trump's team in trying to delay the subpoena.

In dismissing Trump's countersuit, US District Judge Victor Marrero wrote in his ruling that the president's argument made an "extraordinary" reach and was "repugnant to the nation's governmental structure and constitutional values."

Marrero wrote that Trump's argument implied "the constitutional dimensions of the presidential shield from judicial process are virtually limitless."

Until the president leaves office, "his exemption from criminal proceedings would extend not only to matters arising from the 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 ruling said.

Trump's lawyers said they would appeal Marrero's decision.

Read more: The 2nd Trump whistleblower is an IRS official who alleges a Treasury Department political appointee tried to interfere with Trump's tax audit

The Manhattan district attorney's subpoena was part of a broader investigation into whether the Trump Organization and Trump broke New York state laws when reimbursing Trump's former lawyer Michael Cohen for hush-money payments made to women who alleged they had affairs with Trump.

The investigation is said to have begun after federal prosecutors from the Southern District of New York formally closed their criminal probe into the payments in July.

Cohen pleaded guilty in the federal investigation to several counts of bank fraud, tax evasion, and campaign-finance violations. He is serving a three-year sentence in federal prison. CNN reported last month that state prosecutors have already interviewed Cohen as part of their investigation.

The payments being investigated were made to the adult-film actress Stormy Daniels (whose real name is Stephanie Clifford) and to the former Playboy model Karen McDougal.

Cohen acknowledged facilitating both payments but said he did so at Trump's direction. In addition to implicating the president in the scheme, Cohen provided documentary evidence to investigators and lawmakers showing Trump and other senior executives were aware of the payments.

Cohen also testified to Congress earlier this year that Allen Weisselberg, the Trump Organization's longtime chief bookkeeper, witnessed Trump's direct involvement in the illegal hush-money payment to Clifford. Cohen said he and Weisselberg were both in Trump's office when Trump "directed us to go back to Weisselberg's office and figure [the $130,000 payment to Daniels] all out."

The president was not ultimately charged, and it's unclear if he wasn't charged because of a lack of evidence, or because Justice Department guidelines that say a sitting president cannot be indicted.