(Updates with details, background)
SANAA, Dec 5 (Reuters) - At least 20 people were killed on Thursday in a car bomb and gun battle at the Yemeni defence ministry compound in the capital Sanaa, sources inside the complex said, in one of the most serious attacks in the past 18 months.
The defence ministry said the attack targeted the ministry's hospital and most of the gunmen had been killed or wounded.
"The attackers have exploited some construction work there to carry out this criminal act ... the situation is under control," the ministry said in a statement on its website.
No one claimed responsibility for the attack. But the U.S.-allied country has been grappling with a security threat by al Qaeda-linked militants, who have repeatedly attacked government officials and installations over the past two years.
Witnesses said the explosion shook the compound in the old district of Sanaa, where the country's central bank is also located.
"The attack took place shortly after working hours started at the ministry, when a suicide bomber drove a car into the gate," the defence ministry source said.
"The explosion was very violent, the whole place shook because of it and plumes of smoke rose from the building," an employee who works in a nearby building told Reuters.
Ambulance sirens and gunshots were heard after the blast as soldiers exchanged fire with the gunmen, said to have been disguised in Yemeni army uniforms, who had stormed the compound.
A military source said that at least 20 people, including militants, were killed in the attack and dozens were wounded. The Yemeni health ministry appealed to citizens to donate blood to help save the wounded.
At least two sources inside the defence ministry said the attackers came in two vehicles. One was driven by a suicide bomber who attacked the gate of the compound, while armed men entered the compound in the second, the sources said. The ministry statement made no reference to a suicide attacker.
Violence is common in Yemen, where an interim government is grappling with southern secessionists, al Qaeda-linked militants and northern Houthi rebels, as well as severe economic problems inherited from veteran President Ali Abdallah Saleh who was forced out of office in 2011.
The insurgents were emboldened by a decline in government control over the country during protests that eventually ousted Saleh. They seized several southern cities before being driven out in 2012.
Al Qaeda militants have killed hundreds of Yemeni soldiers and members of the security forces in a series of attacks since an offensive, which the United States has supported with intelligence and drones, drove them out of their strongholds.
In July last year, an al Qaeda suicide bomber wearing a Yemeni army uniform killed more than 90 people rehearsing for a military parade in Sanaa. Al Qaeda later claimed responsibility for the attack.
Yemen's defense minister, Major General Muhammad Nasir Ahmad, escaped a car bomb on his motorcade in September 2012 that killed at least 12 other people. (Reporting by Mohammad Ghobari; Writing by Maha El Dahan and Sami Aboudi; Editing by Rania El Gamal, Patrick Graham and Sonya Hepinstall)