Five attackers were killed in the brazen midday attack on the National Directorate of Security (NDS), which is playing an increasingly important role in the war against Taliban insurgents as NATO forces prepare to withdraw.
The Taliban claimed responsibility in a text message to AFP, saying "a large number of intelligence workers were killed and wounded".
"There were five attackers involved. The first detonated a car bomb at the gate, the other four were shot dead by police and NDS guards as they approached," Interior Ministry spokesman Sediq Sediqqi said, adding that about 30 civilians were wounded.
A senior police officer said two guards from the National Directorate of Security intelligence agency were killed and others wounded.
A second car full of explosives was found nearby and defused.
The huge explosion was heard throughout Kabul's diplomatic district, and witnesses said windows were shattered in nearby Chicken Street, a popular shopping destination for Westerners.
AFP journalists at the scene said it was swarming with security forces moments after the attack.
An NDS official, speaking on condition of anonymity, expressed concern over how the attackers had managed to penetrate one of the most heavily-guarded areas of the capital, which includes the police HQ and the Interior Ministry.
"It was a suicide explosion at the gate," he told AFP, adding that gunshots had also been heard.
"It's a big facility and very, very sensitive, with a very high security installation and system," he said.
The NDS plays a crucial role in the fight against the Taliban, who have been waging an insurgency since being ousted from power by the 2001 US-led invasion for harbouring Al-Qaeda leader Osama bin Laden after the 9/11 attacks.
Its chief was wounded in an assassination attempt by a suicide bomber posing as a fake Taliban peace envoy at a spy agency guest house in Kabul on December 6, just months after he took office.
Afghan police and other security forces are increasingly targets of Taliban attacks as they take a bigger role in the fight ahead of the NATO withdrawal.
The NDS influence on the conduct of the war is likely to grow as the US and NATO withdraw the bulk of their 100,000 combat troops from the country by end 2014 and hand responsibility for the war to Afghan forces.
The NDS chief, Asadullah Khalid, is still receiving medical treatment in the United States.
A spokesman for NATO's International Security Assistance Force said no international forces were targeted in Tuesday's attack.
"There was a big boom around noon and then we heard an exchange of fire close to the Green Zone," a diplomatic source told AFP.
After 11 years of war and claims by the US-led NATO force that the insurgency has been weakened, Kabul is regularly targeted in the Taliban's bid to oust the NATO-backed government of President Hamid Karzai.
They also remain active in their traditional strongholds in the south and east of the country, and there are widespread fears of a new multi-factional civil war once the international troops leave.