"Our troops and those from our ally Ethiopia were forced to fire heavy artillery," he told Reuters. "We had to retaliate. These elements are being paid to cause all this destruction."
A woman living nearby said several people were wounded in the surrounding streets, and a Reuters TV cameraman saw five bodies in a western neighbourhood also hit by mortar rounds.
"The favour of Western countries is vital to Somalia's future"
Angus Hogg, Horsham, UK
Send us your views
A spate of near-daily rocket and mortar strikes have challenged the weak interim government's bid to impose security and let Ethiopian troops, who helped it oust the courts, go home.
Salad Ali Jelle, deputy defence minister, said two civilians were killed in the attack on the defence headquarters and accused remnants of the Islamic courts of paying the assailants.
"The insurgents are paying $100 a day to whoever fires rockets and mortars at the government and people," he said.
But a new 24-hour, rapid response paramilitary unit would soon show results in its fight to stop the wave of guerrilla attacks, he said.
The paramilitary force began operations on Monday after being trained by the Ethiopian troops, Jelle said.
"It is a government plan to fight terrorists and bring them to justice," he said.
He did not provide more details but the unit is thought to number about 700 soldiers.
"The plan is to expand our control in the city so the extremists are no longer safe anywhere ... We intend to make it very hard for them to continue operating," Jelle said.
With Ethiopian military help, government troops have boosted patrols and set up more checkpoints.
The attacks underscore the huge challenge facing the interim government of Abdullahi Yusuf, the president, as it tries to tame a nation in anarchy since Mohamed Siad Barre, the former president, was ousted in 1991.
His administration says it is doing its best to police one of the world's most dangerous cities with little help.