Aleppo, Syria (CNN) -- Somehow, the hundreds of thousands of Syrians who can't -- or won't -- leave this battleground city have grown accustomed to living in a state of war.
But they have also shown that they do not want to live in a state of anarchy.
On a side street, not far from where goats graze next to a burned-out ambulance in what used to be a neighborhood park, stand the offices of what can only be described as a rebel court.
The United Courts Council operates without the authority or recognition of any central government. It stands on the opposition-held side of the front lines that divide this city.
This self-appointed council of judges, lawyers and clerics started working four months ago. Judging by the line of supplicants waiting in the halls, residents appear to have granted this court
some degree of popular legitimacy.
In rooms marked "Civil Court" and "Personal Affairs Court," legal workers on a recent day issued birth and death certificates, signed divorce papers and listened to lawyers plead their clients' cases in a family property dispute.
Nobody flinched when blasts from artillery shells rocked nearby neighborhoods.
"We created this temporary judicial council as an emergency solution, like when a doctor removes a bullet from a patient without using anesthetic," said Marwan Gayed.
Gayed is a former appeals court judge who defected from the Syrian government and now serves as the general prosecutor for the United Courts Council. He sat in an office, signing legal documents and stamping them with the council's seal, oblivious to thunderous explosions echoing outside.
"We have a deteriorating humanitarian situation," he added. "We came to work to stop people like the Free Syrian Army or others from taking advantage of the weak and to maintain law and order inside liberated areas." The Free Syrian Army is the main rebel force fighting the government of President Bashar al-Assad.
Even a temporary judicial system requires some system of detention and punishment.
The council has about 100 prisoners detained in a series of makeshift jail cells in a basement that resembles a dungeon.
In the "military prison," a court founded by rebels has incarcerated rebels accused of committing war crimes.
During a visit by CNN journalists, more than a dozen men sat on mats in a cavernous room.
Some of the inmates said they were there on charges of robbery and theft.
Others, like a bearded fighter who called himself Abu Younus, were being investigated for leading men into a battle that resulted in the friendly fire deaths of many fellow rebels. Abu Younus made an emotional plea, declaring his innocence.
"God, you know that I am innocent," he bellowed, raising hands and face to the ceiling. "Please god reveal the truth."
Then he suddenly collapsed on the ground.
"He passes out when he gets excited," a prison guard explained.
Another jailed rebel, who asked not to be named, said, "I am a member of the Free Syrian Army and the captain of a battalion. I tortured a shabiha" -- a pro-government militia-man -- "and he died three days later.
"I turned myself in. And now I'm waiting for the law to take its course ... in this failure of a court."
The jailed rebels were being held in the same prison cell with several captured loyalist soldiers. Men who could have been trying to kill each other on the battlefield weeks ago slept side by side on the floor and shared prison food.
The conditions in the basement prison were grim, dark and cold. Yet at first glance, inmates there appeared to be treated better than at another makeshift rebel jail CNN visited in northern Syria last August.
There, CNN saw more than 40 prisoners being held at a time in a single, over-crowded room. Some of those detainees, especially members of the shabiha militia, showed obvious signs of torture.
At the United Courts Council jail in Aleppo, the prison warden led visitors to another cell, where men sat with their backs to the walls under heavy blankets. Some read books. One inmate read a newspaper.
"This section is for shabiha, informants, collaborators, spies and homosexuals," said the warden, who asked to be named only Abu Abdo.
Abu Abdo, a former officer from Syria's foreign security service, insisted he was trying to reform rather than punish the prisoners by giving them regular lessons in Islam.
In fact, one of the judges explained that he and his colleagues are following a "Unified Arab Criminal Code" adopted by the Arab League, which is rooted in Islamic law.
"This basically follows sharia, while taking into consideration modern Muslim life," said Mohammed Najib Banna.
Banna, who had been a teacher in a religious school and a cleric reading sermons at a mosque, is now a judge in the council's Military Court.
"Our work now will prepare us for the day when the regime falls, because then there will be anarchy," Banna said.
While some of the detainees in the prison are accused of committing crimes on the battlefield, others are detained for charges ranging from adultery to prostitution and "disobeying parents."
This is especially true in the women's jail cell, where most of the inmates hid their faces under blankets during a visit by CNN.
Among the detainees was a teenage girl, the daughter of a couple who were both also incarcerated in the prison.
Some of the women were also accused of spying for the Syrian regime.
One woman stood and repeatedly performed a salute, accompanied by a martial stamp of her foot.
Asked who she was saluting, she listed the names of the father and son who have ruled Syria for 40 years: "President Hafez al Assad, President Bashar Hafez al-Assad."
"May God give victory to Bashar al-Assad," she said with a smile. "Because they're saying lies about him. He's likeable, excellent in every way."
Then she started saluting again.
Another 23-year-old woman who asked not to be named said she had been arrested 16 days previously for being a shabiha.
"I cooperated with the state while I was in university. I used to go and come back and communicate with them," she said. "And I would go to demonstrations supporting the president."
One might assume the United Courts Council had been formed to create a rival judicial structure to the Syrian government, which is believed to control a quarter to a third of Aleppo.
But a visit to the office of Gayed, the council's prosecutor, revealed political tension between rival rebel groups.
The suavely dressed former judge had a half dozen guests seated around his desk, most of whom were lawyers hoping to set up a similar court in the opposition-held northern town of Maraa.
There was also a stocky, bearded man dressed in a camouflage uniform who quickly excused himself after journalists entered the room.
"The man was here from Jabhat al-Nusra," Gayed explained after the man left. "He was asking me to hand over a prisoner to his court system. I said no."
Jabhat al-Nusra, or Nusra Front, is a well-organized Islamist fighting group. The U.S. government recently black-listed the group, accusing of it being a terrorist organization.
"We black-listed the Nusra Front because of its intimate links with al Qaeda in Iraq," said Robert Ford, the former U.S. ambassador to Syria, in an interview with CNN in Turkey.
"Nusra has a sectarian agenda ... (it) is anti-democratic and will seek to impose its very strict interpretation of Islam on Syria," Ford said.
But Gayed, asked about al-Nusra, called its members "our brothers in the revolution. They bleed for it. But we differ on how to build the state."
"We are calling for a civil democratic nation. They call for an Islamic state," he said. "The U.S. and the European Union didn't help us, and that created an increase in Islamic radicalism. ...
"Up until now we can control the situation," Gayed warned. "But later on, we may not be able to contain it."
Gayed argued his council's experiment in rebel justice is a more tolerant alternative to the Islamic courts that Nusra Front has reportedly been establishing in Aleppo and in other rebel controlled towns.
The United Courts Council is working to expand its law-and-order model to other communities in the largely rebel-held north.
It is a desperate strategy, council members admitted, aimed at preventing Syria from descending further into chaos