A suicide bomber struck outside the Afghan interior ministry, allowing gunmen to pass through an outer gate where they traded fire with security forces before they were eventually killed, officials said.
General Daud Amin, the Kabul police chief, said seven attackers were killed and clean-up operations are under way. Interior ministry spokesman Najib Danish said one policeman was killed and five were wounded.
It appeared to be a rare victory for Afghan security forces, who have struggled to secure the capital in recent months.
The Taliban and a local Islamic State affiliate have carried out a wave of attacks, mainly targeting security forces and the country’s Shia minority, killing hundreds of people. Both groups have also expanded their footprint in the countryside.
Elsewhere in Afghanistan, Taliban suicide bombers attacked a police station in the eastern Logar province, killing at least three police.
Among the dead were the commander of the police station and the deputy director of traffic police for the provincial capital, Puli Alim, said Khalid Safi, a spokesman for the provincial governor.
Another four police and eight civilians, including two children, were wounded in the attack early on Wednesday, said Shah Poor Ahmadzai, spokesman for the provincial police chief.
He said the attackers set off a suicide car bomb at the entrance to the station before three suicide bombers tried to enter. All three were shot and killed by security forces within minutes of the initial attack, he said, adding that a number of nearby homes were damaged.
The Taliban claimed the attack.