The attack started at around noon (0730 GMT) when a suicide attacker detonated a large car bomb near a gate of one of the National Directorate of Security's (NDS) buildings, the Kabul police chief's office said in a statement.

Soon after, five men wearing vests packed with explosives and carrying grenades and automatic rifles attempted to storm the compound, but they were shot dead by security forces.

The minivan the group of five men had arrived in was packed with a type of liquid explosive security forces had not encountered before, Tahiri said.

Two of the agency's guards were killed in the blast, which wounded 30 people, security and health officials said.

The bombers managed to breach the heavily barricaded centre of Kabul, home to several Afghan ministries and Western embassies.

"At the heart of Kabul there was a martyrdom attack on Kabul's spy agency by a car loaded with explosives," Taliban spokesman Zabihullah Mujahid said in a statement, referring to a suicide attack.

The security agency's chief, Asadullah Khalid, survived an assassination attempt last month in an attack that threatened to derail an already fragile peace process between the government and the Taliban.

Violence across the country has been increasing over the last year, sparking concern over how the 350,000-strong Afghan security forces will be able to manage once foreign troops withdraw by 2014.

(Additional reporting by Miriam Arghandiwal, writing by Amie Ferris-Rotman and Dylan Welch; Editing by Robert Birsel)