The police said the bomb went off near the heavily fortified zone at about 9 a.m. local time (0600 GMT) on Saturday.
The car packed with explosives sped through a security checkpoint in front of the Wehliye Hotel popular with government officials, lawmakers and the city’s elite, and detonated at the security checkpoint to the national assembly headquarters after being shot at by police officers.
Several people died in the explosion, although police have not announced the exact number of casualties.
After the blast, black smoke was seen billowing in the air while vehicles were left burnt.
No group has yet claimed responsibility for the aback.
Footage from the scene showed debris scattered across the road, and people standing looking on in horror.
It was the latest major terrorist attack in Somalia in recent weeks.
At least eight soldiers, including a senior intelligence commander, were killed last Friday in a roadside bombing claimed by al-Qaeda-linked al-Shabab militant group.
The explosion tore through a military vehicle just outside Dhusamareb district in central Somalia, located some 400 kilometers (250 miles) north of Mogadishu.
Al-Shabab militants, despite being ousted from large parts of south and central Somalia, have been waging an insurgency across the Horn of Africa nation for more than a decade.
Somalia has faced instability and violence since 1991, when the military government was overthrown.
The country is now beset by the growing threat of Daesh as the Takfiri terrorist group is seeking to find a new foothold after being vanquished from Iraq and much of Syria.
Like in the Middle East where it emerged with the deployment of foreign troops, Daesh is rearing its head across Africa amid the presence of forces from the US, France and other countries.