It was not entirely clear how the ruling might affect detention policies for terrorism suspects caught outside Afghanistan or Iraq. While the Obama administration has stepped up the use of Predator drone strikes to kill terrorism suspects and has relied on other countries, like Pakistan, to hold and interrogate suspects who are captured alive, it is not known whether the United States has directly captured anyone outside Afghanistan or Iraq recently — and, if so, where it has taken them.

A Justice Department spokesman, Dean Boyd, would not comment on the decision.

David Rivkin, who filed a friend-of-the-court brief on behalf of the Special Forces Association urging the court to side with the government, said the ruling would have broad significance by removing doubts over whether the United States could capture and interrogate terrorism suspects without worrying about having to collect, in dangerous situations, evidence that would later stand up in court.

“This is an excellent decision,” said Mr. Rivkin, who was a White House lawyer in the administration of the first President Bush. “It has restored a considerable degree of sanity to what threatened to be a crazy legal regime that would have deprived the United States, for the first time in history, of the opportunity to capture and detain — outside of the United States, in theaters of war — high-value combatants. That has been solved, and it will apply to many other situations in the future.”

The case was brought on behalf of a Tunisian man who says he was captured in Pakistan in 2002, a Yemeni man who says he was captured in Thailand in 2002, and another Yemeni man who says he was captured in 2003 at another location outside Afghanistan that has not been disclosed. (The government has disputed the second Yemeni’s claim.)

The men’s case was originally heard by Judge John D. Bates of the Federal District Court, an appointee of former President George W. Bush. The Bush and Obama administrations had both urged Judge Bates not to extend habeas corpus rights beyond Guantánamo, arguing that courts should not interfere with military operations inside active combat zones.

But in April 2009, Judge Bates ruled that there was no difference between the three men who had filed suit and Guantánamo prisoners. His decision was limited to non-Afghans captured outside Afghanistan — a category that fits only about a dozen of the roughly 800 detainees at Bagram, officials have said.

In urging the appeals court to let Judge Bates’s decision stand, lawyers for the detainees argued that reversing it would mean that the government would be able “to evade judicial review of executive detention decisions by transferring detainees into active combat zones, thereby granting the executive the power to switch the Constitution on or off at will.”