The flight of the Islamists was a dramatic turnaround in the volatile Horn of Africa nation after they took Mogadishu in June and spread across the south imposing sharia rule.
Terrified of yet more violence in a city that has become a byword for chaos, some Mogadishu residents greeted the arriving government troops, while others hid.
"People are cheering as they wave flowers to the troops," said resident Abdikadar Abdulle, adding scores of government military vehicles had passed the Somalia National University west of the city center.
Parts of Mogadishu shook with the sound of gunfire and there were outbreaks of looting after leaders of the Somalia Islamic Courts Council fled its base early in the morning. Some fighters ditched their uniforms to avoid reprisals.
"We have been defeated. I have removed my uniform. Most of my comrades have also changed into civilian clothes," one former SICC fighter told Reuters. "Most of our leaders have fled."
The fall of Mogadishu came about 10 days after the Islamists sought to march on the government base of Baidoa. That prompted Ethiopia to come openly into the war, proving the decisive factor in saving the government and pushing back the Islamists.
The SICC had brought a semblance of stability to Mogadishu by using the courts, after chasing U.S.-backed warlords from the city in June. Islamists and residents said order had collapsed with their departure.
"Mogadishu is now in chaos," Islamist leader Sheikh Sharif Ahmed told Al Jazeera television.
Ethiopian Prime Minister Meles Zenawi confirmed the advance to the outskirts of the capital and vowed to pursue the Islamist leaders. "We will not let Mogadishu burn," he added.
Government spokesman Abdirahman Dinari said government forces had secured the main routes into Mogadishu. "We are taking control of the city and I will confirm when we have established complete control," he said.
He said the Islamists had fled to the southern port city of Kismayu and the administration controlled 95 percent of the Horn of Africa country.
The government declared a state of emergency "to control security and stability."
SICC leader Ahmed said his side's hasty withdrawal was a tactical move in a war against Ethiopian troops defending Somalia's weak, Western-backed government.
Many had predicted the Islamists would wage a guerrilla war if dealt a resounding blow in the first round of war.
Islamist defense lines were routed by a joint force of Ethiopian armor and government fighters.
Pro-government militias who once held sway in Mogadishu said they had captured several key buildings early on Thursday, including the former presidential palace.
Witnesses reported looting late on Wednesday and the sound of gunfire in a sign that one of the world's most dangerous cities may be sliding back to the rule of the gun.
"My worst fear is the capital will succumb to its old anarchy," said resident Muktar Abdi. "The government should come in now and take over -- this is the best chance they have before the city falls into the hands of the warlords again."
Chaos, gunfire and looting
Ahmed said the Islamists were united and determined to push out Ethiopian forces, but retreated to avoid more bloodshed.
By fleeing, the Islamists appeared to have averted the risk of becoming embroiled in the fierce street fighting that forced the U.S. military from Mogadishu more than a decade ago in a humiliating episode captured in the film "Black Hawk Down."
Dinari said President Abdullahi Yusuf remained in the government's south-central base Baidoa, but Prime Minister Ali Mohamed Gedi was flying closer to the front.
The government has long viewed Mogadishu as too dangerous to move to but its return would be a massive step in achieving greater legitimacy as the 14th attempt to restore central rule since the 1991 ouster of a dictator.
The government maintained an amnesty offer to all Islamist fighters who laid down their arms.
More than a week of mortar and rocket duels between the Islamists and the Ethiopian-backed government spiraled into open war 10 days ago. With Eritrea accused of backing the Islamists, many had feared the conflict would engulf the Horn.
Ethiopia, like the United States, says the Islamists are supported by al Qaeda. It says it has taken foreign prisoners and killed radicals from abroad, including some with British passports.
The SICC has depicted the conflict with Christian-led Ethiopia, which has one of Africa's most effective armies, as a holy war against "crusaders," tapping into decades of rivalry between the two neighbors.
Somalia refugees drown
Yemeni authorities opened fire on boats filled with refugees fleeing the fighting in Somalia and at least 17 people drowned when one of the vessels capsized, the U.N. refugee agency said Thursday. About 140 people were still missing.
The incident took place late Wednesday in the Gulf of Aden when four boats smuggling 515 people were spotted by Yemeni authorities, UNHCR said.
The authorities opened fire, causing two of the boats to try to escape, the agency said. Yemeni authorities were searching for survivors, the UNHCR said.Copyright 2006 Reuters. All rights reserved