BEIRUT, Lebanon — Ahmed Hamadeh had spent a year in a jail in a Damascus suburb when guards chained him to fellow inmates, marched them to an outlying military checkpoint, and ordered them to dig trenches for the soldiers. He concluded that the government had “lost its mind,” he recalled later, not only because the move risked a jailbreak, but also because of the arbitrary violence that followed.

Groups of five prisoners remained chained together, he said, even when they slept and relieved themselves. Those who grew exhausted were shot; Mr. Hamadeh, who had been picked up at a checkpoint for leading antigovernment protests, said he was forced to help carry away two bodies.

Weakened by a diet of eggshells, watermelon rinds and two daily pieces of bread, he held out for 12 days until a guard warned that he would be next, he said. The next day — on the Night of Power during the holy month of Ramadan, when prayers are believed to gain special force — Mr. Hamadeh and his four workmates used shovels and rocks to break their shackles and ran. Within days he was leading protests again. He called his escape “a miracle.”

Mr. Hamadeh’s account, told over Skype, and those of other former prisoners suggest an uneven mix of control and chaos inside Syria’s prisons and detention centers, laced with episodes of unpredictable cruelty. Government opponents believe that more than 200,000 people have been held in those jails in connection with the country’s civil war.