WASHINGTON — A federal appeals court ruled on Friday that Congress could not sue to enforce its subpoenas of executive branch officials, handing a major victory to President Trump and dealing a severe blow to the power of Congress to conduct oversight.

In a ruling that could have far-reaching consequences for executive branch secrecy powers long after Mr. Trump leaves office, a divided three-judge panel of the U.S. Court of Appeals for the District of Columbia Circuit dismissed a lawsuit brought by the House Judiciary Committee against Mr. Trump’s former White House counsel, Donald F. McGahn II.

On Mr. Trump’s instructions, Mr. McGahn defied a House subpoena seeking to force him to testify about Mr. Trump’s efforts to obstruct the Russia investigation. The House sued him, seeking a judicial order that he show up to testify, and won in district court in November.

But two of the three appeals court judges ruled on Friday that the Constitution gave the House no standing to file any such lawsuit in what they characterized as a political dispute with the executive branch. If their decision stands, its reasoning would shut the door to judicial recourse whenever a president directs a subordinate not to cooperate with congressional oversight investigations.

“The committee now seeks to invoke this court’s jurisdiction to enforce its subpoena,” wrote Judge Thomas B. Griffith. The Justice Department, “on behalf of McGahn, responds that Article III of the Constitution forbids federal courts from resolving this kind of interbranch information dispute.”

“We agree and dismiss this case,” he wrote.

Judge Griffith said that Congress had political tools to induce presidents to negotiate and compromise in disputes over oversight demands for information about the government — like withholding appropriations or derailing the president’s legislative agenda — and that courts should not be involved.

“The absence of a judicial remedy doesn’t render Congress powerless,” he wrote, adding, “Congress can wield these political weapons without dragging judges into the fray.”

But the dissenting judge, Judith W. Rogers, warned that the ruling would embolden presidents to flout legislative oversight and deprive lawmakers of a powerful tool to obtain information they sought, undermining core prerogatives of Congress enshrined in the Constitution.

“The court removes any incentive for the executive branch to engage in the negotiation process seeking accommodation, all but assures future presidential stonewalling of Congress, and further impairs the House’s ability to perform its constitutional duties,” she wrote.

The ruling deflates a primary argument used by Mr. Trump’s defense team to question the legitimacy of the impeachment process. His lawyers insisted that the House should have pursued all of its legal avenues to secure testimony rather than charging the president with obstruction of Congress. But even as the impeachment trial unfolded, the Justice Department was arguing in the McGahn case that such lawsuits were invalid and, ultimately, the court adopted that reasoning.

Brianna Herlihy, a spokeswoman for the Justice Department, which was defending Mr. McGahn in court, said the Trump administration was “extremely pleased” with the ruling, calling it historic.

“Suits like this one are without precedent in our nation’s history and are inconsistent with the Constitution’s design,” she said. “The D.C. Circuit’s cogent opinion affirms this fundamental principle.”

Spokesmen for Speaker Nancy Pelosi of California and Representative Jerrold Nadler of New York, the chairman of the House Judiciary Committee, had no immediate comment. But it seemed likely that the House would appeal to the full appeals court to rehear the case.

Both judges in the majority were appointed by Republican presidents — Judge Griffith was appointed by George W. Bush and Judge Karen L. Henderson, who joined him in the decision, was appointed by George Bush. Judge Rogers was appointed by President Bill Clinton, a Democrat.

The ruling was the latest in a string of developments that have eroded Congress’s power to subpoena information from the executive branch. Originally, Congress was understood to have “inherent contempt” power to arrest recalcitrant witnesses, but that is now seen as unrealistic.

Under administrations of both parties, the Justice Department has refrained from charging executive branch officials with criminal contempt of Congress for refusing to comply with a subpoena when the president has invoked executive privilege, even when Congress disputes whether the invocation was valid.

Against that backdrop, the prospect of a civil lawsuit asking a judge to order an executive branch official to comply with a subpoena has been the rare remaining tool to incentivize presidents to negotiate with Congress in an information dispute and try to reach an accommodation.

The case against Mr. McGahn was only the first of several brought last year against the executive branch by House Democrats seeking to enforce their subpoenas. Others included efforts to obtain Mr. Trump’s tax returns and internal documents showing why his administration tried to include a citizenship question on the 2020 census.

Mr. Trump had instructed Mr. McGahn not to show up, declaring that his former legal aide was “absolutely immune” from being compelled to testify about his duties, meaning he had no obligation to appear.

In a twist, Judge Henderson wrote in a concurring opinion that she disagreed with that argument. Along with Judge Rogers’s rejection of it, that meant there was a shadow majority against the absolute-immunity theory. But because Judge Henderson joined Judge Griffith in asserting that Congress could not file lawsuits to enforce its subpoenas in the first place, it did not matter.

A Federal District Court judge rejected the absolute immunity theory in a 2008 case involving a congressional investigation into the Bush administration’s firings of United States attorneys, one of the first lawsuits by Congress to enforce a subpoena for executive branch information. The case was resolved, however, without any definitive appeals court ruling.

In 2012, there was another subpoena lawsuit brought by House Republicans related to the botched gun-trafficking case known as Operation Fast and Furious. That case involved documents, not testimony, and it was also resolved without any definitive appeals court ruling on whether the House had a right to bring it in the first place.

Late last year, after House Democrats sued Mr. McGahn, another lower-court judge rejected the claims that the House had no standing to sue and that a former top White House aide is absolutely immune, ordering him to comply with the subpoena.

But in throwing out the case, Judge Griffith worried that the judiciary was getting increasingly dragged into sticky political disputes. He pointed out that if Mr. McGahn did show up but Mr. Trump then invoked executive privilege to block him from answering specific questions, the same matter would end up right back in court.

Judge Rogers, however, noted that at least since the Watergate scandal nearly 50 years ago, the threat of a potential lawsuit has hung over such negotiations. Removing that threat, she argued, would thus disrupt — not reaffirm — the process for resolving information disputes.

“Future presidents may direct wide-scale noncompliance with lawful congressional inquiries, secure in the knowledge that Congress can do little to enforce a subpoena dramatically undermining its ability to fulfill its constitutional obligations now and going forward,” she warned.