"A car loaded with explosives rammed the gate and there is gunfire inside the building of the ministry," police official Mohamed Dahir said.
Witness Idil Malim reported seeing several dead bodies.
"There were several people lying dead at the scene," he told AFP, although police said that with the attack continuing they could not confirm casualties.
The building is in the K5 district of the capital, which has been hit by a string of similar attacks in recent months.
A car bombing to force entry into fortified buildings followed by an armed raid has become a trademark tactic of the hardline Islamists.
Somalia has been unstable since the collapse of Siad Barre's hardline regime in 1991, and the country's new government is being supported by a 22,000-strong African Union force that includes troops from Burundi, Djibouti, Ethiopia, Kenya and Uganda.
Shebab fighters have carried out a string of revenge attacks in neighbouring countries, notably Kenya and Uganda, in response to their participation in the AU force.
