Ethiopian troops are very unpopular with Mogadishu's residents
There have been celebrations in the Somalia capital Mogadishu after Ethiopian troops withdrew from their two main bases in the city.
People are returning to homes evacuated after the Ethiopians intervened two years ago to oust Islamist forces.
Their pull-out has stoked fears of a highly volatile power vacuum but others say it could pave the way for peace.
A ceremony was held in the city to mark the handover of security to government forces and moderate Islamists.
A small African Union peacekeeping force remains in Mogadishu but analysts say it is not strong enough to withstand the Islamists, who once more control much of southern Somalia.
The US wants the United Nations to take over peacekeeping duties.
Ethiopia agreed to pull out last October as part of a UN-backed peace deal between the fragile transitional government and one of the main opposition factions.
One of the Ethiopian bases was reportedly immediately taken over by an insurgent group opposed to the peace deal which paved the way for the withdrawal.
When Mogadishu residents heard about it on Tuesday morning, they flocked to the area to see the empty bases for themselves.
"We were chanting 'Praise be to Allah', who made the troops leave our area," local man Hussein Awale told Reuters news agency.
Prime Minister Nur Hassan Hussein praised the Ethiopian forces saying: "We congratulate them for the good work they did. We also congratulate them for implementing the peace agreement," reported the AFP news agency.
Ethiopian commander Col Gabre Yohanes Abate said: "It is time Somalia stands on its own feet," according to the AP news agency.
"So we are saying goodbye to all Somalis and their dignitaries."
Islamist insurgents control much of Mogadishu now
Some 16,000 civilians have been killed in the conflict between Somalia's transitional government and the Islamists, and a million more have been forced from their homes.
Ethiopia has fought two border wars with Somalia and its intervention was deeply unpopular, united disparate groups against their presence.
Western diplomats hope their withdrawal could reduce support for hardline Islamists and lead to moderates joining a government of national unity.
The BBC's Mohamed Olad Hassan in Mogadishu says the Ethiopians withdrew from two bases in the north-east of the city, where there have been daily clashes between them and insurgents.
Our reporter says there are three remaining military bases, but the withdrawal from the strategic north-east of the city is seen as a strong signal that the Ethiopians are leaving.
A small group of Ethiopian troops has been seen heading for the border in recent days.
Uganda, Burundi and Nigeria are willing to send extra troops but the African Union has no money to pay for them and is wary of taking on an open-ended commitment.
Increasingly urgent efforts are now going on to strengthen the small African Union force.
Potential donor countries have been invited to a meeting this Saturday at African Union headquarters.
Many of the city's residents get caught in the daily skirmishes
The UN special representative to Somalia, Ahmedou Ould-Abdallah, told the BBC he was in favour of any plan, including that proposed by the US, for a UN peacekeeping force in Somalia.
"I will be supportive of any resolution adopted by the [UN] Security Council," he said. "Somalia has been left alone for a long time in the hands of some people doing what they want."
Last month UN Secretary General Ban Ki-moon said few countries were willing to send troops to Somalia, as there was no peace to keep.
Somalia has not had an effective national government since 1991, since when various militias have been battling for control.