This article was produced in partnership with the Pulitzer Center on Crisis Reporting.

WASHINGTON — A federal judge has ordered the United States military to have a panel of American and foreign doctors examine a Saudi man who was tortured at Guantánamo Bay to determine whether he should be released from the prison there and sent home for psychiatric care.

The 25-page opinion issued Friday by U.S. District Judge Rosemary M. Collyer is a departure from the court’s usual deference to the military on medicine at the wartime prison at the U.S. Navy base in Cuba. It also gives foreign doctors a decisive say in determining, for the first time, whether to release a detainee from Guantánamo Bay.

Judge Collyer wrote that she was granting a request by lawyers for the prisoner, Mohammed al-Qahtani, to compel the United States to apply an Army regulation designed to protect prisoners of war and to create “a mixed medical commission” made up of a medical officer from the U.S. Army and two doctors from a neutral country chosen by the International Committee of the Red Cross and approved by the United States and Saudi Arabia.

Mr. Qahtani, who is in his 40s, had a history of profound mental illness and psychiatric hospitalization in Saudi Arabia before he left in 2000 or 2001. He was captured along the Pakistan-Afghanistan border after the Sept. 11, 2001, terrorist attacks and subjected to two months of continuous, brutal interrogation by the U.S. military inside a wooden hut at Camp X-Ray at Guantánamo in late 2002 and early 2003, after the military closed that particular detention facility.