"Operations finished. All suicide bombers killed & more than 2000 civilians staff rescued," the Ministry of Interior said on Twitter.
A few hours earlier, an explosion and gunfire were reported in the centre of the Afghan capital, close to the communications ministry buildings.
"Around 11:40 am (7:10 GMT) an explosion was heard near the communication ministry, and sporadic firing has also been heard in the area", Interior Ministry spokesman Nasrat Rahimi said.
The Tolo News television channel reported, citing witnesses that attackers were allegedly fighting security forces on the first floor of the ministry building. At the same time, Reuters reported, citing an anonymous security official that the blast appeared to have been caused by a suicide bomb at the entry to the ministry.