Islamist fighters have left the Somali capital as government forces backed by Ethiopian troops advance on the city.
Ethiopian-backed government troops are close to Mogadishu
As they withdrew, gunfire was heard and armed supporters of the city's warlords began taking control of key facilities.
Some residents say lawlessness has returned to Mogadishu - which had been under Islamic rule for six months.
Ethiopia began a large-scale offensive at the weekend to back Somalia's interim government, capturing ground previously held by Islamist militias.
A senior Islamist leader, Sheikh Sharif Ahmed, told al-Jazeera television his forces had left Mogadishu "to avert heavy bombing because Ethiopian forces are practising genocide against the Somali people".
The BBC's Mohammed Olad Hassan in Mogadishu says clan militiamen appeared as soon as the news of the withdrawal emerged early on Thursday, and UIC offices have been looted.
Residents in the north of the city have reported cars and mobile phones being stolen.
Rising insecurity has forced most businesses to stop trading.
The situation seems to be descending back into anarchy, our correspondent adds.
Observers say the UIC's departure leaves a power vacuum in Mogadishu, raising fears of a return to clan warfare that has plagued the city and Somalia for 16 years.
Government forces are reported to be near Afgoye, 20km (12 miles) west of Mogadishu, cutting off the capital to the north and west.
Government spokesman Abdirahman Dinari said the army would enter Mogadishu in the "coming hours".
Militias allied to the government have taken control of key installations, including the airport, AFP news agency reports.
Islamic fighters are said to have fled towards the port city of Kismayo, their last remaining stronghold, 300 miles (500km) to the south.
But a senior UIC official Omar Idris said the retreat was "not the end".
He told the BBC's World Today radio programme: "We know what happened in Iraq... I think this is very, very early to say that the Islamic Court forces were defeated."
At the weekend Ethiopia began a major offensive to support the weak government against the UIC - which previously held much of central and southern Somalia.
The conflict has killed hundreds of people. The head of the International Red Cross Somalia delegation said it was "extremely concerned about civilians caught up in the fighting".
The African Union has called for Ethiopian forces to leave Somalia.
However the UN Security Council has failed to agree on a statement calling for the withdrawal of all foreign forces.
A special adviser to Ethiopian Prime Minister Meles Zenawi, Bereket Simon, declined to specify when his country's troops would leave.
"It all depends on how we find the extremist groups whether they are trying to reorganise," he said
The UIC has its roots in the north of the capital Mogadishu.
Courts administering Islamic law restored order in a city bedevilled by anarchy since the overthrow of former President Mohamed Siad Barre in 1991.
The UIC assumed control of the whole capital in June, driving warlords out and rapidly extending their influence to much of southern Somalia - with the exception of Baidoa, the seat of the transitional Somali government.
That body, set up in 2004 after talks between Somali factions, has been unable to meet in the capital because of opposition first from warlords, then from the UIC.
UIC leader Sheikh Hassan Dahir Aweys is accused by both Ethiopia and the US of having links to al-Qaeda - charges he denies.