Islamic State claimed responsibility for the attack through its propaganda arm.

Militants stormed an intelligence agency training facility in Kabul on Monday, officials said, triggering intense fighting with police in the latest Islamic State group attack to hit the Afghan capital.

“Around 10:10 am, a group of armed attackers entered an under-construction building in (the) NDS training centre in (the) Afshar area of Kabul,” interior ministry spokesman Najib Danish told AFP, referring to the National Directorate of Security, Afghanistan’s spy agency.

“The fighting is ongoing and we have also launched our operation.”

Nasrat Rahim, a deputy interior ministry spokesman, said the sound of large and small arms fire could be heard from the fighting.

"There are three attackers involved... the clearance operation is ongoing," said the spokesman, adding there were no immediate reports of any casualties.

Roads to the area were closed and dozens of police and intelligence officers were blocking access to the public. AFP reporters, who were held more than a kilometre away from the scene, saw ambulances and reinforcements headed towards the site.

“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.

IS claimed responsibility for the attack through its propaganda arm.

"Two IS attackers raid the Afghan intelligence centre in Kabul," the jihadists' Amaq outlet reported.

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 IS both step up their attacks, targeting security installations and mosques.

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.

No group has officially claimed responsibility for that attack, which the government has blamed on the Taliban-allied Haqqani Network.

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 US 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 IS, which has expanded its presence in Afghanistan since it first appeared in the 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 IS.