Suicide bombers have attacked a building belonging to Afghanistan's National Directorate of Security (NDS) in the capital, Kabul, officials have told the BBC.
Six suicide attackers and an Afghan security guard were killed. At least 17 civilians were injured.
A minibus was detonated but another bomb-laden car defused, police said.
The Taliban, who have launched several high-profile raids on Kabul, said they were behind the attack.
The BBC's Bilal Sarwary in Kabul says the attacked area is often packed with civilians who come to collect passports and national identity cards at the interior ministry.
Intelligence chief Gen Zaher Zaher told the BBC the clearance operation was now over.
The area affected in central Kabul is heavily barricaded - and the NDS compound, which also houses several Western embassies, is surrounded by tall, thick cement walls designed to protect it from bomb blasts.
A senior Afghan security official told the BBC that the attackers targeted the NDS unit where suicide attackers and key Taliban commanders are interrogated.
The NDS said that one suicide attacker drove a minibus which exploded outside the NDS building.
Five others, armed with semi-automatic weapons and hand grenades, then fought the security forces for 15 minutes before being killed by guards.
According to the NDS, another vehicle packed with explosives was defused shortly afterwards.
The main explosion took place around noon local time (07:30 GMT). A plume of smoke rose from the area, and gunfire and police sirens were then heard.
One eyewitness, Mohammad Zia, told Associated Press that the vehicle with the bomb inside drove up to the gates of the barricaded NDS building and then was detonated.
A number of wrecked cars could be seen.
Shop owner Qais Ahmad told Reuters: "I was inside the shop when I heard noises and a huge bang. All the windows in my shop were destroyed and injured my head."
The attack comes shortly after the return from the US of President Hamid Karzai, who was discussing the future of his country after the Nato-led troops withdraw at the end of next year with President Barack Obama.
Wednesday's attack on the embassy area of Kabul is the first since November, when a suicide bomber killed two Afghan security guards and wounded three.
Last month, NDS chief Asadullah Khalid was wounded in a Taliban suicide bombing in the Taymeni area of central Kabul.
The Taliban said the attacker had posed as a peace messenger.
Mr Khalid has been in the job since September and has a reputation for being fiercely anti-Taliban.
Militant groups continue to mount regular attacks in Afghanistan, raising questions as to how the Afghan security forces will cope after 2014.