Outgoing Defense Secretary Donald H. Rumsfeld is asking a federal judge to dismiss a lawsuit that would hold him personally responsible for allegations of torture in overseas military prisons.

The lawsuit, filed by two civil rights groups, describes the imprisonment of nine foreigners detained in Iraq and Afghanistan. The lawsuit contends the men were beaten, suspended upside down from the ceiling by chains, urinated on, shocked, sexually humiliated, burned, locked inside boxes and subjected to mock executions.

President George W. Bush has called the abuse of prisoners at Abu Ghraib prison in Iraq the biggest mistake of the war.

Attorneys for the American Civil Liberties Union and Human Rights First say Rumsfeld and top military officials authorized such abuses and should be held liable in federal court.

The Justice Department argues that Rumsfeld cannot be sued. Government officials are generally immune from lawsuits related to their jobs unless they violate a constitutional right.

A hearing before U.S. District Judge Thomas F. Hogan, set for Friday, will focus on whether Rumsfeld has official immunity. Rumsfeld, who has announced his resignation and will be replaced this month by Robert Gates, is not expected to attend.

The civil rights groups say Rumsfeld violated the prisoners' right of due process and to be free of cruel and unusual punishment. The government argues that foreigners held outside the United States do not have constitutional rights.

If the court lets the lawsuit continue, the Justice Department said, it would allow prisoners around the world to use U.S. courts to disrupt military operations.

"Subjecting military leaders to such personal tort liability could distract them from their duties, and the specter of captured aliens harassing military personnel with time-consuming individual capacity litigation could cause grave damage to military morale," the government wrote in briefs filed with the court.