NEW YORK — President Trump's latest attempt to shield his tax records from the Manhattan district attorney was rejected Thursday by a federal judge who said Trump's legal team failed to show the subpoena was issued "in bad faith," as they had argued.

U.S. District Judge Victor Marrero threw out Trump’s lawsuit attempting to block the subpoena, which his lawyers have called “overbroad” in its request for documents and tantamount to “harassment.” Manhattan District Attorney Cyrus Vance Jr., who is seeking eight years of the president’s financial records from his accounting firm, has argued the grand-jury subpoena is legally valid and tied to a legitimate criminal investigation.

“The Court finds that the President has not sufficiently pled that the subpoena is overbroad or was issued in bad faith on this basis,” the judge wrote in his ruling, which follows a major Supreme Court opinion last month that determined Trump, as sitting president, was not immune from state court actions or criminal investigation.

Vance has been investigating hush-money payments made ahead of the 2016 election to two women who alleged having affairs with Trump years ago, claims the president has denied. The district attorney’s office recently suggested it is also looking at potential bank and insurance fraud related to the Trump Organization.

Shortly after Marrero’s decision was announced Thursday, Trump’s legal team filed an emergency motion asking the judge for a delay in enforcing the subpoena so Trump may appeal. The team also asked a federal appeals court and the U.S. Supreme Court to intervene and stay the judge’s ruling — preventing the subpoena from being enforced while the case is appealed again.

Asked about the ruling, Trump predicted the case would eventually end up back at the nation’s highest court.

“Well, the Supreme Court said if it’s a fishing expedition, you don’t have to do it, and this is a fishing expedition,” the president told reporters at the White House. “But more importantly, this is a continuation of the witch hunt, the greatest witch hunt in history. There’s never been anything like it.

The district attorney’s office has argued that Trump is attempting to impede its investigation from moving forward. Impending statutes of limitations are nearing and could hinder authorities from pursuing charges if a case is warranted, Vance’s team has told the court.

Last August, Vance sent a subpoena to Trump’s accounting firm, Mazars USA, asking for Trump’s tax returns as well as other documents including “Statements of Financial Condition” that Trump used to tout his wealth to potential lenders.

Those statements sometimes exaggerated Trump’s assets or omitted properties with large debts, according to a Washington Post analysis. But versions viewed by The Post also carried disclaimers at the front, written by Mazars, warning that they were not compiled using standard accounting practices.

Vance’s subpoena was for Mazars. It did not ask for anything from Trump himself. But Trump sued to block it.

His argument was that he was immune from prosecution — or even investigation — by state or local law enforcement, simply because he is president. There was little precedent for that claim. But Trump’s lawyers said his immunity was so broad that he could, in theory, shoot someone on Manhattan’s Fifth Avenue and not be prosecuted.

“Local authorities couldn’t investigate? They couldn’t do anything about it?” an appellate judge asked one of Trump’s attorneys in a hearing last year. “Nothing could be done? That is your position?”

“That is correct,” said Trump’s private attorney William Consovoy. He said Trump could be investigated only after he left office.

That argument was rejected by the Supreme Court. But the high court said Trump could still challenge Vance’s subpoena on the same grounds that any private citizen could — that Vance was asking for too much or asking for the wrong reasons.

Trump did.

He said that Vance’s subpoena was an effort at political retaliation, noting that it asked for many of the same documents as a subpoena from a Democrat-led House committee investigating Trump’s compliance with tax laws. And Trump argued that the subpoena asked for documents too far removed from the hush-money payments, which he asserted was the focus of Vance’s investigation.

But in his decision Thursday, Marrero rejected both arguments.

He said that the law presumes subpoenas are issued for a valid purpose, unless proved otherwise. And Trump did not prove otherwise.

“Justice requires an end to this controversy,” Marrero wrote.

Even if Vance’s subpoena is enforced and the district attorney’s office receives Trump’s tax returns, there is no guarantee the public will see them — soon or ever.

The documents will be secret, under the rules of grand-jury investigations. If Vance’s office decides to charge someone with a crime, they might emerge later as evidence in court briefs or a trial.

Mazars has said in the past that it would fully comply with its legal obligations. The firm declined to comment Thursday.

Fahrenthold reported from Washington. Felicia Sonmez contributed to this report.