Fighters linked to al-Qaeda have stepped up attacks on the government in the past two months, to try and oust Sheikh Sharif Sheikh Ahmed, the Somali president.
Fierce clashes have killed nearly 300 people since early May.
Bodies lay in the streets and hospital wards were packed with casualties on Wednesday.
Dahir Dhere, deputy director of the Madina hospital in Mogadishu, said: "We have received 50 people injured in today's fighting."
Western nations, some of Somalia's neighbours and the government fear that if the chaos persists, foreign fighters will be sucked into nation, increasing risks to the region in general.
"We do not have a specific number, but at least 500 fighters are in Mogadishu alone and I think this is a great danger to the entire region," Omar Abdirashid Ali Sharmarke, the Somali prime minister, said.
"Some middle ranking al-Qaeda officials came into the country and they want to make a base in Somalia," he told the Reuters news agency in Nairobi, Kenya.
"If these guys succeed in taking over Somalia, they will create havoc in the continent."
Police chief killed
Among the victims of Wednesday's violence was Ali Said, a Mogadishu police chief.
People in various parts of the city were struck by stray bullets.
"The commander died in the fighting this morning when the troops overran the opposition trenches," Abdiqadir Odweyne, a senior police official, said.
The al-Shabaab group has so far resisted government attempts drive its fighters from Mogadishu and the fighters, along with its allies Hizbul Islam, now control most of southern Somalia bordering Kenya and parts of the central region.
Analysts say the fighting in Mogadishu is the worst for years and the chances of any negotiated peace are waning.
African Union peacekeepers are protecting vital Somali sites, but government forces have so far lacked the strength to win back territory within or outside Mogadishu.
The government says it is confident of retaking major towns, but has called on African and Western nations to deliver on promises of logistical and financial support.