Somalia offered an amnesty to militants still fighting in the capital, Mogadishu, on Tuesday, three days after the country’s president declared victory over the insurgent group al-Shabab, which has withdrawn most of its combatants from the city.

It was the first time the interim government, which has struggled to quash a four-year-old Islamist rebellion, had offered immunity to al-Shabab fighters.

“The Transitional Federal Government of Somalia has offered a general amnesty to insurgent fighters remaining in Mogadishu who give themselves up and renounce violence,” the government said in a statement.

Some experts say al-Shabab’s pullout merely extends the government’s hold on the capital by a few districts and will do little to bring tangible peace to the rest of the anarchic country. Some have suggested that it may herald a new wave of al-Qaeda-inspired attacks.

Meanwhile, the 9,000-strong African Union peacekeeping force urged the deployment of an additional 3,000 troops to help it secure the neighborhoods vacated by al-Shabab on Saturday.

The United Nations has authorized a task force of up to 12,000 troops.

A Western diplomat, who spoke on the condition of anonymity, said the militants’ withdrawal had caught the Somali government and peacekeepers off-guard.

Issuing a warning about al-Shabab, the diplomat said, “It’s only a question of time before we see them back in a different form” in Mogadishu.

Fears were also voiced that warlords could step into the void left by al-Shabab’s departure.

“If the TFG overplays its hand and tries to assert a hegemony in the vacuum left by the retreating militants, it risks provoking a very strong reaction by clans and local communities . . . to which it has never provided any services,” said J. Peter Pham, an analyst with the Atlantic Council think tank.

The amnesty did not appear to extend to al-Shabab fighters outside the capital. The al-Qaeda-affiliated militants control much of southern Somalia, where 2.8 million people face starvation because of drought and conflict.

Al-Shabab described its retreat from Mogadishu as tactical and said its bloody struggle to topple the Western-backed government would continue.

On Monday afternoon, an explosives-laden car heading for the rubble-strewn capital detonated prematurely eight miles south of Mogadishu.

Gun battles raged overnight in at least two northern districts of the city, and residents said government forces and al-Shabab also traded volleys of mortar rounds.

Mohamed Abdullah, who lives in Mogadishu’s Hosh neighborhood, said the militants, who want to impose Islamic law, or sharia, on the famine-stricken population, launched an assault on two government military bases.

“We weren’t expecting such attacks from al-Shabab now. Clearly the group is still present and still has some power,” Abdullah said.