The Islamist militia that now controls Somalia's capital, Mogadishu, has emerged out of a judicial system funded by the powerful business community to try and bring some law and order to a country without a government.
But over the past two years, the Union of Islamic Courts has emerged into Somalia's strongest fighting force - forcing the warlords who have controlled the capital for the past 15 years into retreat.
Sharif Sheikh Ahmed is the moderate chairman of the courts
BBC Somali Service editor Yusuf Garaad Omar says they are the most popular political force in the country.
There are 11 autonomous courts in Mogadishu, some of which have periodically tried to clamp down on robbery, drugs and what they say are pornographic films being shown in local video houses.
At first they concentrated on petty crime but by the mid 1990s they had progressed to dealing with major crimes in north Mogadishu.
Thieves had their limbs amputated and murderers were executed.
Mr Garaad says that despite protests from human rights bodies, north Mogadishu residents were pleased to enjoy law and order - in stark contrast to south Mogadishu, where crime was rampant.
The system has since further expanded and the Islamic courts also validated transactions such as the purchase of houses and cars.
They also oversaw weddings and divorces and expanded their authority across most of the capital, while staying out of politics.
"They were really trusted by the people, who had no other institution to go to," Mr Garaad says.
The Islamic courts say they want to promote Islamic law rather than clan allegiance, which has divided Somalis over the past 15 years.
However, all but one of the 11 courts is associated with just one clan - the Hawiye, who dominate the capital, but they are divided into sub-clans.
In order to avoid accusations of clan bias, each court would try members of their own sub-clan, wherever the alleged crime was committed.
Some clan elders in north Mogadishu have now set up their own court, independent of the union.
The union's public face is its chairman Sharif Sheikh Ahmed, a moderate who sought to assure Somalis and the international community this week that the Islamic Courts were no threat and only wanted order.
Mr Ahmed, 32, is a law graduate from Libya and former secondary school geography teacher.
But the union does contain radical elements.
Many Somalis have turned to Islam during the years of anarchy
Two of the 11 courts are seen as militant; one is led by Sheikh Hassan Dahir Aweys, on an American list of terrorism suspects because he used to head al-Itihaad al-Islamiya, which was linked to al-Qaeda.
Mr Aweys says al-Itihaad no longer exists and also denies accusations from some western diplomats and observers that there are training grounds for Islamic fighters in Somalia.
He is, however, strongly critical of the United States and its "war on terror".
Western diplomats are also concerned by Afghanistan-trained militia commander Adan Hashi Ayro, whose militiamen have been implicated in numerous killings of Somali nationals, as well as five foreign aid workers and a BBC producer, Kate Peyton.
But Somalia is a strongly Islamic country and many people support the courts.
During the years of warfare and anarchy, many Somalis have increasingly turned to their faith for some sort of stability.
One visible sign is that before the civil war began in the 1980s, very few women wore headscarves in Mogadishu.
Sheikh Aweys denies there are al-Qaeda training camps in Somalia
Now, almost every woman wears a headscarf and an increasing number are wearing veils covering their faces, with just narrow slits for the eyes.
Even those Mogadishu residents who are wary of Islamic extremism may welcome a single group being in control of the capital for the first time in 15 years, saying there will at least be some authority.
And most will prefer Islamic preachers to the warlords who have repeatedly fought over and in many cases systematically looted the city since 1991.
BBC Somali analyst Yusuf Garaad Omar says the warlords were hated - even more so because of the widespread belief that they were being backed by the US.
The US has not been well thought of in Somalia since its humanitarian intervention went disastrously wrong - leading to the death of maybe 1,000 Somalis and 18 US troops in 1993.