(CNN) -- Al-Shabaab has withdrawn from Somalia's war-ravaged capital in what the Islamist militant group called a "change in tactics."
The Somali president said Al-Shabaab, which controls much of southern Somalia, retreated from Mogadishu after heavy fighting early Saturday with government and African Union forces.
The al Qaeda-linked group has been waging an insurgency against Somalia's transitional government since 2006.
"Al-Shabaab and al Qaeda are a menace to Somalia and it is happy news that we defeated them in Mogadishu," Somali President Sheikh Sharif Sheikh Ahmed told reporters.
But he warned Mogadishu residents not to rush to areas vacated by Al-Shabaab fighters, saying the group may have booby-trapped the area. He also warned of possible suicide bombings.
U.N. special representative Augustine Mahiga lauded the retreat, saying "there is no doubt that the departure of Al-Shabaab would be a positive development and a step in the right direction for a city that has seen so much misery and devastation."
Spokesman Sheikh Ali Mohamud Rage confirmed Al-Shabaab fighters left the city but said the fighting was hardly over.
"The reasons we withdrew from Mogadishu is we have made changes in our tactics of war," he told the group's radio station, Andalus. "We withdrew because we want to save lives of the poor civilians but we will launch operations against government (and African Union) forces in the coming hours."
Some believe the Islamists withdrew because of funding woes and drought-related issues.
The United Nations has declared famine in five areas of southern Somalia in June, including Mogadishu. In all, about 12 million people in the Horn of Africa region need assistance. Somalia is the worst hit.
"The immediate priority must now be to focus on the humanitarian situation and I call on all parties, from the donor community to all parts of the Transitional Federal Government, to do everything possible to ensure and facilitate the immediate delivery of assistance to those most in need," Mahiga said.
Al-Shabaab has called the famine a "crusader" invention and an excuse for occupation, and issued threats to aid agencies delivering food to afflicted areas.
As crops withered, thousands of people fled and livestock starved. But the militants kept their ban on aid groups operating in their territory in southern and central Somalia, and parts of the capital.