Among the dead are six women and a family of five whose home was smashed by shelling, said Ali Muse, the head of Mogadishu's ambulance service. He said at least 61 other civilians were wounded in the heavy shelling and gunbattles that started early Thursday in northern Mogadishu.
A senior Somali military official claimed victory and said government forces will hold on to the areas they captured Thursday.
"We have driven insurgents from a large swath of the capital and we will not withdraw from those conquered areas like we used to do before," said Gen. Ali Araye, the infantry commander.
He also said there will be further offensives against the insurgents. Araye, however, said this is not the start of the government's long-awaited offensive to drive out Islamic insurgents from Mogadishu.
Al-Shabab spokesman Sheik Ali Mohamud Rage denied that his group's militiamen were defeated during Thursday's attack. Instead, he said, they had inflicted casualties on government forces, but he did not give any figures.
Araye declined to comment on casualties.
The government's offensive against the insurgents has been repeatedly delayed since the beginning of the year. According to some officials the delays have been partly due to the Somali army's lack of equipment, training and a reliable system to pay its soldiers.
Since early last year government forces have been on the defensive, losing huge portions of Mogadishu to the powerful insurgent groups who have even come within striking distance of the presidential palace.
But government forces now appear determined to beat back militants. On Thursday they succeeded in routing insurgents from several of their northern Mogadishu strongholds, said resident Hassan Abdullahi.
Thursday's shelling disrupted businesses in the city's largest trading center, Bakara market. Some of the shelling, mainly fired from government positions and African Union bases, randomly hit southern and northern parts of the war-scared city, Muse said.
The market is usually bustling with business despite tensions in the capital. The area it is in, however, is controlled by al-Shabab and its allied group, Hizbul Islam. Over the past three years the market has seen near-daily shelling between militants, and the AU and Somali soldiers.
Mogadishu has been the epicenter of the country's 19 years of conflict and lawlessness and Islamic insurgents control much of the city. They have been trying to topple the present fragile government for three years but the Horn of Africa nation has been without an effective central government since 1991 when warlords overthrew longtime dictator Mohamed Siad Barre.
Associated Press writer Malkhadir M. Muhumed in Nairobi, Kenya contributed to this report.