Islamist fighters have withdrawn from most of their bases in Somalia's capital Mogadishu, paving the way for aid agencies to get food to more starving people in the famine-ravaged capital.

Militants had been denying the agencies access to areas they had control over, complicating relief efforts amid one of the worst humanitarian crises to hit the impoverished east African nation.

The government said Saturday that humanitarian groups were now free to distribute their food. Government soldiers and peacekeepers with the African Union force took up positions in abandoned militant posts, including the city's former sports stadium.

The militant fighters, who call themselves al-Shabab, controlled a third of the capital until Saturday morning. They carried out public amputations and executions and forcibly recruited children.

starving-woman-300-01085756

More than 12 million people in the Horn of Africa are in need of immediate food aid. (Farah Abdi Warsameh/Associated Press)

Al-Shabab, which has been linked with extremist group al-Qaeda, still controls most of southern Somalia, where tens of thousands are estimated to have starved.

More than 12 million people in the Horn of Africa are in need of immediate food aid. The UN says 640,000 children in Somalia alone are acutely malnourished. The UN has declared five famine zones in Somalia, including the refugee camps of Mogadishu.

Aid officials say the famine has killed more than 29,000 children in the last 90 days.

Government troops fire on refugees

Food distribution is chaotic in the city. There have been two deadly shoot-outs involving government forces in the past week after aid agencies tried to hand out sacks of food.

On Friday, Somali government troops opened fire on hungry civilians, killing at least seven people, as both soldiers and civilians made a grab for food at a United Nations distribution site.

Witnesses accused soldiers of sparking a stampede by trying to steal some of the 290 tonnes of dry rations aid workers were trying to hand out in the biggest camp in Mogadishu for famine refugees.

The present situation echoes the events of 1992 that prompted deployment of a U.S.-led multinational force to safeguard the delivery of food to Somalia's starving.

That international intervention collapsed in 1993 after two U.S. Black Hawk helicopters were shot down and militias hired to protect the aid operations ended up looting vast amounts of food.

Fighters join general population

The withdrawal of the rebel fighters was orderly according to witnesses.

Ali Mohamed Rage, spokesman for the al-Shabab fighters, vowed in an interview with a local radio station that the fighters would return and said the withdrawal was a tactical move.

Somali Prime Minister Abdiweli Mohamed Ali described the militants' withdrawal as the "first phase of the new war."

But Lt. Col. Paddy Ankunda, a spokesman for the 9,000-strong AU force, cautions that many rebels have melted into the population.

Somalia hasn't had a functioning government for 20 years. Ali's administration has made little effort to provide services to its citizens despite receiving tens of millions of dollars in cash from foreign donors. Ali vowed he would declare such donations in the future to make it more transparent as to where that money was being spent.

With files from The Associated Press