Militants stormed an intelligence agency training center in Kabul on Monday in an attack claimed by the Daesh terrorist group, triggering an intense gunbattle with Afghan police.
Security forces battled the militants, besieged in a construction site at the National Directorate of Security (NDS), for hours before killing at least two attackers.
"They were well hidden in buildings under construction. We exploded their VBIED and killed two or three of them," a source with the NDS told AFP on condition of anonymity, referring to a car bomb that attackers brought to the scene.
Kabul police spokesman Basir Mujahid said two police officers were injured but there were no civilian casualties.
During the attack, roads to the area were closed and dozens of police and intelligence officers blocked access to the public.
"I was going toward my school. It (the attack) happened suddenly... the police arrived in the area fast and blocked the roads, not allowing anyone to get to their homes," Naweed, a student, told AFP.
Daesh claimed responsibility for the attack through its propaganda arm.
"Two IS attackers raid the Afghan intelligence center in Kabul," the terrorists' Amaq outlet reported, using an alternate acronym for the group.
The Afghan capital has become one of the deadliest places in the war-torn country for civilians in recent months, as the resurgent Taliban and increasingly the Daesh terrorist group both step up their attacks.
Security in Kabul has been ramped up since May 31 when a massive truck bomb ripped through the city's diplomatic quarter, killing about 150 and wounding around 400 people, mostly civilians.
Monday's attack represents another blow to beleaguered Afghan forces.
The Taliban have targeted military installations in recent months, including a spate of attacks in October that killed around 150 people.
Afghan forces, already beset by desertions and corruption, have seen casualties soar to what a U.S. watchdog has described as "shockingly high" levels since NATO forces officially ended their combat mission in 2014.
Morale has been further eroded by long-running fears that the militants have insider help -- everything from infiltrators in the ranks to corrupt Afghan forces selling equipment to the Taliban.
But Daesh, which has expanded its presence in Afghanistan since it first appeared in region in 2015, has also dramatically scaled up its attacks in Kabul, including on the country's Shiite minority.
In November, a suicide attacker blew himself up outside a political gathering in Kabul, killing at least 14 people in an attack claimed by Daesh.