Residents said the government soldiers were backed by AU peacekeepers in armoured vehicles.
Some of the shelling, mainly fired from government positions and AU bases, randomly hit southern and northern parts of the war-scared city, Muse said.
A senior Somali military official claimed victory and said government forces will hold on to the areas they captured.
"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," General Ali Araye, the infantry commander, said.
He also said there will be further offensives against the fighters.
Araye, however, said this is not the start of the government's long-awaited offensive to drive out fighters from Mogadishu.
Sheik Ali Mohamud Rage, al-Shabab's spokesman, denied that his group's fighters were defeated during Thursday's attack, saying that they had inflicted casualties on government forces.
Al-Shabab fighters are trying to hold on to the city's north, which puts the presidential palace, known as Villa Somalia, within easy range of their crude mortar rockets.
Last month, al-Shabab claimed its forces would soon seize the palace.
Tensions also remained high in the Galgadud region of central Somalia where clashes betweenal-Shabab and the Ahlu Sunna Waljamaca group, a pro-government militia, killed 24 people on Wednesday.
Thursday's shelling disrupted businesses in the city's largest trading centre, Bakara market.
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 fighters, and the AU and Somali soldiers.
Somalia has had no effective government for 19 years and Western nations and neighbours say the country is used as a shelter by fighters planning attacks in East Africa and further afield.
More than 21,000 civilians have been killed since the start of the violence.