Col. Greg Julian, a spokesman for the United States Southern Command, which oversees Guantánamo, said steps had been taken the address the concerns. “There are comprehensive programs in place now that ensure everyone receives the appropriate training, and reviews and follows” the standard operating procedures, he said.

Among the lapses identified in the report were around staffing. Guards would take turns watching Mr. Latif because he would engage in “indecent behavior,” often leaving gaps of several seconds each time guards traded places.

In addition, it says, corpsmen had grown lax about following procedures that required watching a detainee swallow medicine and were depositing dosages in trays at cell doors.

Mr. Latif was transferred to another cell the day before he died, raising questions about how he could have moved contraband medication. The report says guards did not search his Koran or take another step that was redacted; an official familiar with the report said the censored sentence referred to not searching private areas on detainees’ bodies.

The military released the report in response to a Freedom of Information Act request by Jason Leopold, who has written for Truth-out.org and Al Jazeera.

Mr. Latif traveled from Yemen to Pakistan in August 2001, and later made his way into Afghanistan, where he was captured trying to flee after the war began. He insisted that he was not a jihadist and that he had been seeking medical treatment from a charity for lingering problems related to a brain injury he had sustained in a car accident.

But the military said he had confessed under interrogation early in his capture to having gone to help the Taliban fight the Northern Alliance. Still, executive branch panels under both the Bush and Obama administrations recommended repatriating him, and in 2010, a federal judge ordered his release. But by then, President Obama had imposed a ban on any transfers to Yemen, which he lifted only last month.

The Justice Department appealed the decision, and in 2011 an appeals court ruled that the administration could lawfully keep imprisoning him. The report says that Mr. Latif’s final “downward spiral of behavior” began in June 2012, when he learned in a phone call from Mr. Remes that the Supreme Court had declined to hear his appeal.