An image obtained by the Associated Press shows an unidentified detainee standing on a box with a bag on his head and wires attached to him in the Abu Ghraib prison in Baghdad. (AP)

A federal judge said Friday he would consider whether to dismiss a lawsuit against the military contractor alleged to have orchestrated torture of detainees at Abu Ghraib prison in Iraq because of a legal doctrine that prevents him from second-guessing military decisions.

After a lengthy hearing in federal district court in Alexandria, Judge Gerald Bruce Lee said he needed more time to decide whether Virginia-based CACI Premier Technology can be exempted from a lawsuit because of the so-called political question doctrine, which bars a court from deciding political matters. Lee asked a multitude of questions during the hearing and seemed to take notes, though his inquiries did not reveal which way he might be leaning.

The lawsuit, filed by four Iraqis who were held at Abu Ghraib, alleges that CACI employees ordered military police officers to deprive detainees of sleep, repeatedly beat them and subject them to an array of other horrors that were uncovered after the release of photos from the prison.

Lee had previously tossed the case in 2013 — saying the U.S. District Court in Alexandria did not have jurisdiction to rule on the incidents that happened overseas — but an appeals court overruled him and sent the case back his way.

CACI — which insists there is no evidence to connect any of its employees to torture — argued the suit would force Lee to second guess military judgments, and the law does not permit him to do that. The company argued its employees answered to military supervisors and operated under military policies, and it was not appropriate to “sit and judge and instruct on what should have been done 10 years ago.”

“As we see it, this is the military’s show,” CACI lawyer John O’Connor said.

Lawyers for the detainees argued that CACI interrogators had effectively gone rogue, thanks to a “profound command vacuum” that existed at Abu Ghraib. They asked the judge not to confuse the “legitimate authority to lawfully interrogate individuals” with a “license to torture,” and argued that they were only asking the judge to hold the contractors to policies that should have prevented torture.

“We’re not questioning military judgments. We’re seeking to enforce them,” said Baher Azmy, the legal director of the Center for Constitutional Rights and a lawyer for the detainees.

Lee said he would weigh the parties’ arguments and issue a written ruling.

No matter what he decides, the case is far from over. If he were to throw out the case, the detainees could again appeal. If he were to allow it to move forward, CACI could file other challenges. Their lawyer hinted at a few in court Friday, arguing, for example, that it would be logistically impossible for the case to proceed to trial because three of the four people suing cannot come to the United States.