The attack happened while parliament was in session to pass a motion asking leaders of the shaky government to appear within three days for a vote of confidence.

One member of parliament was wounded in the face and five government troops were also hurt. Government and African Union troops responded by firing into the main Bakara Market. At least 12 people were killed and 40 were wounded there, said Ali Muse, the head of Mogadishu's ambulance service.

The legislators accuse Somalia's transitional government of failing to perform its duties, including trying to foster peace between the country's warring factions and increasing humanitarian efforts.

Somalia hasn't had a functioning government since 1991, when warlords overthrew the president. The country's most dangerous militant group, the Al-Shabab, has increased attacks on the government complex and is believed responsible for Thursday's attack. The militants who control much of this Horn of Africa country want to overthrow the government.

In a hospital run by Burundian peacekeepers, small children flinched as AU and government troops fired their own mortars.

"We need peace so badly," said 17-year-old year old Kalima Abdi, who lay under a blue mosquito net. "The fighting is too much."

Abdi was paralyzed a month ago by a mortar that was fired at an African Union base but landed on her house, killing her seven brothers and sisters.