WASHINGTON (AP) — A federal appeals court ruled Friday against four British men who contend they were systematically tortured and their religious rights abused throughout their two-year detention at Guantanamo Bay.

In a suit against ex-Defense Secretary Donald Rumsfeld and individual U.S. military officials, the four British men argued that the defendants had engaged in criminal conduct.

The U.S. Court of Appeals for the District of Columbia Circuit ruled 3-0 that the four men should have invoked a different law when they filed their lawsuit.

"Criminal conduct is not per se outside the scope of employment," a requirement for bringing a claim under the Alien Tort Statute, said the decision by appeals judge Karen LeCraft Henderson, an appointee of President Bush's father.

The four men challenge the methods Rumsfeld and the military officers used, but the former detainees don't allege that the defendants "acted as rogue officials or employees who implemented a policy of torture for reasons unrelated to the gathering of intelligence," the court said.

"Therefore, the alleged tortious conduct was incidental to the defendants' legitimate employment duties," the ruling added.

The four also brought constitutional claims and claims under the Geneva Conventions and the Religious Freedom Restoration Act.

Rejecting all of the men's allegations, the appeals court overturned the only part of a lower court decision that had gone in the detainees' favor. That was the alleged violation of the Religious Freedom Restoration Act.

"Because the plaintiffs are aliens and were located outside sovereign United States territory at the time their alleged RFRA claim arose, they do not fall" within the definition of those allowed to invoke the law, the court ruled.

The other two judges in the case are Janice Rogers Brown, an appointee of President Bush; and A. Raymond Randolph, an appointee of Bush's father.

The defendants in the case include retired Gen. Richard Myers, former chairman of the Joint Chiefs of Staff. The four who sued are Shafiq Rasul, Asif Iqbal, Rhuhel Ahmed and Jamal Al-Harith, all British citizens and residents. They were sent back to Great Britain in 2004.

The appeals court ruling comes at a time when the Supreme Court is considering whether other prisoners still detained at Guantanamo Bay have a right to challenge their confinement in U.S. courts.

Rasul, Iqbal and Ahmed allege they traveled to Afghanistan from Pakistan to provide humanitarian relief the month after the Sept. 11 attacks. Al-Harith says he traveled to Pakistan the same month to attend a religious retreat.

All four wound up at Guantanamo Bay. There, they allege, they were beaten, shackled in painful stress positions, threatened by dogs, subjected to extreme medical care and communication. They also allege they were harassed while practicing their religion, including forced shaving of their beards, banning or interrupting their prayers, denying them copies of the Koran and prayer mats and throwing a copy of the Koran in a toilet bucket.

Al-Harith says that he was first imprisoned by the Taliban who accused him of being a British spy. When the Taliban fell, he says he contacted British embassy officials to secure his evacuation, but that U.S. forces in coordination with British officials sent him to Guantanamo.

The case in the appeals court ruling is Rasul v. Myers, 06-5209.