A federal judge on Thursday rejected President Trump’s latest effort to block the Manhattan district attorney from obtaining his tax returns, roundly dismissing Mr. Trump’s arguments that the prosecutor’s grand jury subpoena was “wildly overbroad” and issued in bad faith.

The ruling by Judge Victor Marrero of Federal District Court in Manhattan marked another setback for the president in his yearlong fight to block the subpoena.

The conflict has already reached the Supreme Court once and could end up there again as Mr. Trump’s lawyers quickly filed papers saying he would appeal. The legal wrangling means an ultimate decision is unlikely before the November presidential election.

The district attorney, Cyrus R. Vance Jr., a Democrat, has been seeking eight years of Mr. Trump’s personal and business returns and other financial records as part of an investigation into the president’s business practices.

The Supreme Court, in a landmark decision last month, denied Mr. Trump’s initial argument that a sitting president had immunity from criminal investigation. But that ruling opened the door for the president to return to the lower court in Manhattan and raise other objections to the subpoena.

Mr. Trump renewed his fight with an argument that the subpoena was seeking information far beyond the jurisdiction of a local district attorney. His lawyers also argued it was issued in a “fit of pique,” simply copying a subpoena issued by congressional Democrats who had been frustrated in their efforts to obtain Mr. Trump’s financial information.

But in his decision, Judge Marrero dismissed the president’s new objections, saying that the judicial process did not “transform automatically into an incidence of incapacitating harassment and ill will merely because the proceedings potentially may implicate the president.”

The judge was appointed to the federal bench in 1999 by President Bill Clinton.

Judge Marrero also agreed with prosecutors that throwing out the subpoena would effectively shield the president and his associates from an investigation, potentially allowing the statute of limitations to expire on any potential crimes. That would give the president the protection he had failed to win from the Supreme Court, the judge ruled.

“At its core, it amounts to absolute immunity through a back door,” Judge Marrero wrote in his 103-page decision.

Reacting to the judge’s ruling, Mr. Trump told reporters in the Oval Office, “This is a continuation of the witch hunt, the greatest witch hunt in history. There’s never been anything like it.”

He added: “We’ll probably end up back in the Supreme Court.”

A spokesman for Mr. Vance declined to comment.

Soon after Judge Marrero’s decision was released, William S. Consovoy, a lawyer for the president, filed an emergency motion asking the judge to bar Mazars USA, the president’s accounting firm, from turning over Mr. Trump’s tax returns and other financial records to the prosecutors until Mr. Trump can appeal.

It has been known that Mr. Vance was investigating whether any New York State laws were broken when hush-money payments were made in the run-up to the 2016 presidential election to two women who said that they had affairs with Mr. Trump.

But Mr. Vance’s office suggested recently in a court filing that its inquiry was broader, also focusing on potential bank and insurance fraud.

The prosecutors, defending their subpoena for Mr. Trump’s records, cited undisputed “public reports of possibly extensive and protracted criminal conduct at the Trump Organization.” Mr. Vance’s office made it clear in court recently that it viewed the tax returns as central evidence in its investigation.

The New York Times also has reported that Mr. Vance’s office issued a separate subpoena last year to the president’s longtime lender, Deutsche Bank, seeking records that Mr. Trump and his company provided to the bank when he sought loans. The bank complied with the request, The Times reported, although there was no indication the bank’s records included Mr. Trump’s tax returns.

Breaking with a 40-year presidential tradition, Mr. Trump has not released his tax returns and has aggressively fought attempts to obtain them.

His lawyers successfully sued to block efforts to gain access to his returns and other financial records made by Democrats in Congress and New York legislators. After Mr. Trump challenged a California law requiring presidential primary candidates to release their tax returns, a federal judge ruled in his favor. But the arguments in those cases had been made on narrower grounds.

Mr. Vance’s subpoena for Mr. Trump’s returns was first sent in August 2019 to Mazars USA.

The following month, Mr. Trump filed suit in Federal District Court in Manhattan, where he made his initial argument about immunity.

Judge Marrero, in a decision last October, rejected that position, calling the argument that Mr. Trump was immune from criminal investigation “repugnant to the nation’s governmental structure and constitutional values.”

In that ruling, Judge Marrero also said that barring more evidence from the president, he did not believe the district attorney was acting in bad faith.

Eventually, the case reached the Supreme Court, which last month ruled against Mr. Trump by a vote of 7 to 2. “No citizen, not even the president, is categorically above the common duty to produce evidence when called upon in a criminal proceeding,” Chief Justice John G. Roberts Jr. wrote for the majority.

Chief Justice Roberts said, however, that Mr. Trump still could raise objections to the scope and relevance of the subpoena, which resulted in the president’s new arguments before Judge Marrero.

“The Mazars subpoena is so sweeping,” Mr. Trump’s lawyers told Judge Marrero in court papers last month, “that it amounts to an unguided and unlawful fishing expedition into the president’s personal financial and business dealings.”

Mr. Vance’s office repeatedly accused the president of using delay tactics to keep from having to comply with a lawful subpoena.

Even if Mr. Vance were to obtain the tax records, they would be covered by grand jury secrecy rules and would most likely not become public. The records might surface in public only if charges were later filed and the records were introduced as evidence in a trial.