"Four civilians died in Wardhigley district and three others were killed in Holwadag and Bakara area. It was the worst fighting we have seen recently," Mohamoud Ahmed, a local resident, said.
Ali Musa, head of Mogadishu's ambulance services, said medics had collected around 22 injured from several locations in the city and "several people" had died.
"I don't have the full figures but I know that three of the dead are a mother and her two children," he said.
The armed group al-Shabab, whose leader late last year proclaimed his allegiance to al-Qaeda's Osama bin Laden, issued a statement claiming responsibility for Friday's shelling.
"The violent elements attacked government positions overnight, firing mortar rounds and machine guns."
Abdullahi Hassan Barisse, police spokesman
"Our holy warriors launched a fierce offensive on several locations in Mogadishu where the apostate militias and their Christian backers were stationed," the group said.
It referred to government troops, who they accuse of being puppets of the West, and to AU peacekeepers who they routinely describe as crusaders bent on introducing Christianity to Muslim Somalia.
In the statement, al-Shabab said two of its fighters had died in the clashes.
Somali government officials were not able to provide more details on the casualties.
"The violent elements attacked government positions overnight, firing mortar rounds and machine guns. The government forces defeated them," Abdullahi Hassan Barisse, a police spokesman, told reporters.
The densely-populated neighbourhoods where the fighting took place, halfway between the airport and the port, is on the edge of an area controlled by the African Union peacekeeping mission (Amisom).
Civilians there are often caught in the crossfire between Amisom troops and al-Shabab.
The clashes marred plans to celebrate the first anniversary of the election of Sharif Ahmed, the Somali president.
Officials had been preparing for celebrations in the presidential compound's theatre on Friday.