Islamabad, Pakistan (CNN) -- Seven men detained by Pakistan's spy agency, the ISI, appeared in court Monday in a landmark case that places one of the nation's most powerful institutions under the scrutiny of its highest court.
The men -- who appeared to be in pain and poor health -- hobbled into the courthouse, surrounded by dozens of armed police officers and family members. Several of the detainees covered their faces. At least two carried urine drainage bags in their hands.
"We didn't have proper food and (were) never offered a doctor while in custody," detainee Abdul Basit said. "I challenge anyone who says I am guilty. We were told we were innocent. Is this a result of our innocence?"
A lawyer representing Basit and the six others detainees argues that they were arrested without due process and injured while in Inter-Services Intelligence custody since 2010.
"When they (the court) asked us to bring them forward (Monday), most of them couldn't even walk. We had to give them support," attorney Tariq Asad said.
ISI attorney Raja Muhammad Irshad offered an explanation for the detainees' condition.
"You can imagine, when somebody is in custody or jail, you can't have the facilities you have at home," he told CNN after Monday's hearing.
Pakistan's Supreme Court ordered the government to give each detainee a medical exam and report the results in four days. The court also ordered the spy agency to produce all documents related to the detention of the men by the first week of March.
Monday's hearing came after the court gave the spy agency a deadline to bring the detainees to court. The deadline was originally set for last Friday, but later it was extended to Monday.
The ISI has also been ordered to explain the deaths of four other detainees.
The lawyer for the ISI has said the four men died of natural causes and the agency denies having anything to do with the condition of the other seven.
Irshad said Monday that documents from the agency would provide more information. The agency has denied any role in the deaths.
The men were initially arrested in 2007 and 2008 and accused of being suspects in militant attacks targeting army bases. They were acquitted and freed in 2010, then detained again by ISI.
The ISI's attorney has said all 11 detainees -- the seven who remain in custody and four who died -- were detained legally under the Army Act, a law that says the army can detain men on suspicions of terrorism or if they are deemed to be a danger to the state.
The Supreme Court case breaks new ground in that the ISI has long been thought untouchable. Legal proceedings in the nation's highest civilian court could expose the inner workings of the secretive agency like never before.
Few people have ever challenged the ISI, Pakistan's most feared and shadowy institution. The spy agency has been accused of backing and toppling politicians, using militant groups as proxies and backing extrajudicial killings.
The ISI has denied the accusations, but no one from the agency ever speaks publicly on camera and no one from the ISI has ever been put on trial.
Journalist Nasir Habib contributed to this report.