A suicide car bomb blew up at the gates of the complex in Sanaa’s Bab al-Yaman district, at the entrance to the old city, and a gunbattle followed at a hospital inside.
At least two foreign medical staff are among the dead, medical sources say.
Yemeni security forces are fighting regional rebels and al-Qaeda, while combating lawlessness and army splits.
Defense Minister Mohammed Nasser is currently on a visit to Washington.
No group has said it carried out Thursday’s attack.
Correspondents say it bears the hallmarks of al-Qaeda in the Arabian Peninsula (AQAP).
However, one government minister has blamed people linked to former President Ali Abdullah Saleh.
Officials said the situation was under control and most of the gunmen had been killed.
“The attack took place shortly after working hours started at the ministry when a suicide bomber drove a car into the gate,” a ministry source said, quoted by Reuters.
The blast was heard hundreds of metres away.
“The explosion was very violent, the whole place shook because of it and plumes of smoke rose from the building,” an eyewitness told the agency.
Officials said a second car followed whose occupants opened fire at the complex, and a battle ensued involving gunmen in military uniforms.
The gunmen occupied a hospital at the complex, they added, but security forces later regained control of the building, which was badly damaged.
“The assailants took advantage of some construction work that is taking place to carry out this criminal act,” the defense ministry said.
They were said to be armed with assault rifles, hand grenades and rocket-propelled grenades.
“Most” of the gunmen were killed, officials said, but it was not clear how many were involved.
The incident comes to aid tight security in the last few weeks following a series of hit-and-run attacks on officials by militants on motorbikes, blamed on AQAP.
VJ-GfjFrGP0Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…