Four people were killed on Saturday when a car laden with explosives blew up near the parliament building in the Somali capital, a police official said.
The Somali terror group al-Shabab, which has recently targeted parliamentarians, claimed responsibility.
Capt Mohammed Hussein said the car exploded at a checkpoint where it had been stopped by Somali troops. The dead were soldiers and refugees from an internal refugee camp near the checkpoint, Hussein said.
Troops had ordered the driver of the car out of the vehicle for a search when he detonated the explosives, Hussein said. Seven children from the camp were wounded in the attack.
Somali legislators were holding a meeting at the parliament at the time of the attack, but al-Shabab did not say what the intended target was.
Al-Qaida-linked al-Shabab has said it was responsible for the killing of a Somali lawmaker and his bodyguard in a drive-by shooting earlier this week.
The targeting of members of parliament appears to be a new strategy for al-Shabab. The parliament is seen as an emerging pillar of democracy in the war-ravaged Horn of Africa nation.
Al-Shabab militants have previously carried out attacks against United Nations staff, government officials and African Union peacekeepers.
The group has launched attacks in neighbouring countries including Kenya and Uganda, which have sent troops to Somalia under the banner of the African Union to bolster the country’s weak UN-backed government.
Last month al-Shabab claimed responsibility for attack on the Kenyan coast that left 65 people dead.
Last year al-Shabab killed 67 people in an attack an upscale mall in Nairobi, the Kenyan capital.