The deadly attack in Kabul comes as families bury the dead from a recent suicide bombing.
Gunmen attacked an intelligence training centre in Kabul on Thursday, officials said, as families buried loved ones killed by a suicide bomber a day earlier in the war-weary Afghan capital.
The attack on the training facility was the latest incident in a blood-soaked week that saw militants deliver crippling blows to government forces across Afghanistan.
"Clashes are ongoing and the area is cordoned off by the Afghan security forces," said Kabul police spokesman Hashmat Stanikzai.
The firefight erupted near a training centre overseen by the National Security Directorate - Afghanistan's intelligence agency - with the gunmen holed up in a construction site near residential buildings, an official at the scene said.
Live television footage showed humvees patrolling the empty streets while gunfire echoed and a helicopter circling above.
Commandos were also deployed to the scene to help contain the fighting, according to another security official.
There was no immediate claim of responsibility for the incident.
The attack comes just hours after a suicide bomber detonated explosives inside an education centre in a predominantly Shiite area of western Kabul, where students were studying for college entrance exams, killing at least 37 people.
The attack was claimed by the Islamic State (IS) group Thursday via their Amaq propaganda service, as families of the dead held a mass funeral where mourners wept and clutched the wooden coffins.
An industrial-sized digger helped soften the arid ground for the fresh graves as men removed rocks from the soil with pickaxes.
Mourners decried the unrelenting bloodshed, while others dismissed murmurings of possible ceasefires and peace negotiations between the government and the Taliban, even though the attack was claimed by IS.
"Death to your ceasefire and death to your ghost peace talks," cried one of the funeral attendees. "They are killing our educated people and everyday they are killing us."
The surge in violence comes just weeks after Afghans marked an unprecedented country-wide ceasefire between the Taliban and government forces in June, giving some temporary relief to civilians.
The brief respite sparked hopes the truce could clear the way for talks to end the nearly 17-year-old conflict.
However the devastating attacks across the country in recent days have led many to question how such negotiations could move ahead.
"Everyday we are witnessing deadly attacks in Kabul and other major cities. So, I believe the Taliban do not believe in peace talks," said shopkeeper Shahenshah Shahin in Kabul.
Analysts have suggested the Taliban may be trying to shore up its position before any potential negotiations by proving they can hit government installations at will.
"The Taliban will try to have an upper hand during talks, so we can't rule out more attacks until a ceasefire," said Taliban expert Rahimullah Yusufzai.
"It's the fighting season and the Taliban will want to rack up victories before winter."
While it has been months since The Taliban have claimed a major attack in Kabul, the group has been conducting blistering attacks on security forces across Afghanistan, including a massive, days-long onslaught on the eastern city of Ghazni during the past week.
Afghan forces appeared to have finally pushed Taliban fighters from the strategic provincial capital, as the UN warned that reports suggested up to 150 civilians might have been killed in the fighting.
Militant attacks and suicide bombings were the leading causes of civilian deaths in the first half of 2018, a recent UN report showed.
Small pockets of Ghazni began opening up to humanitarian aid Thursday, while partial mobile service returned after telecommunications infrastructure and government buildings were destroyed during the onslaught.