Farah Aden Omar, who saw the casualties by looking from the roof of her house, told Reuters news agency: "I saw three dead men and six wounded people, but I could not go out of the house."
Medics at the Madina hospital said they had received 29 wounded people, one of whom died.
Somali police said that an operation was under way.
Abduwahid Mohamed, a police spokesman, said: "This operation is aimed at cracking down [on] insurgents who have been killing people in recent months."
Since Ethiopian and Somali troops defeated the Union of Islamic Courts, a Muslim militia that briefly controlled the capital early this year, Mogadishu has seen a rapid rise in violence, including an increase in crime targeting civilians.
Government forces and AU peacekeepers have failed to quell the violence that has killed hundreds of people and has prevented the delivery of aid to displaced civilians in and around the capital.