Interior Ministry spokesman Nasrat Rahimi confirmed there had been gunfire around the ministry of communications and information technology, but provided no further details.
A loud explosion and follow-up gunfire were heard near the Afghan communication ministry in central Kabul on Saturday, officials said.
Both Taliban insurgents and the Islamic State group are active in eastern Afghanistan and have previously claimed attacks in Kabul. Four other assailants then entered the ministry, the police spokesman said.
After nearly five hours of fighting, security forces killed the remaining four attackers, Mojahid said.
The official said some 2,700 government employees and civilians were rescued by security forces after being stuck in several government buildings.
Live footage on local TV showed government employees fleeing neighbouring Information and Culture Ministry buildings, with some climbing out of windows.
"Around 11:40 am [07:10GMT], an explosion [was] heard near the communication ministry, and sporadic fires have also been heard in the area", Rahimi said.
The Serena Hotel, which is heavily fortified, is one of the few still used by foreign tourists.
Taliban in a statement rejected any involvement in the attack.
The communications ministry is located in Kabul's second police district, one of the busiest spots in the city, about two kilometres from the green zone.
Afghan president Ashraf Ghani strongly condemned the attack in a statement, saying the enemies of Afghanistan, by targeting civil servants, are trying to create terror among the people.
The talks, which had been scheduled for April 19, were considered a significant first step toward finding a negotiated end to the war in Afghanistan and the eventual withdrawal of US troops. The explosion comes the week after the Taliban announced their annual spring offensive and amid ongoing fighting across Afghanistan.
This week in the Qatari capital Doha, a summit planned between the Taliban and officials from across Afghanistan was scrapped at the last minute due to bickering over who should attend the conference.
The militants now control or influence about half the country, and a year ago was the deadliest yet for civilians.
How Mueller made his no-call on President Trump and obstruction
In this week's WhoWhatWhy podcast, Kendzior, the no-holds-barred commentator, calls special counsel Robert Mueller incompetent. But many were nervous about how Trump would react to their testimony and whether it would damage their relationships with him.