Another 10 people were wounded in the hours-long assault that ended with four attackers killed, interior ministry spokesman said.
An hours-long gun and suicide attack on a Kabul government compound killed at least 43 people, the health ministry said Tuesday, making it one of the deadliest assaults on the Afghan capital this year.
Another 10 were wounded in Monday's raid on a site where the Ministry of Public Works and other offices are located, spokesman Waheed Majroh said.
Gunmen stormed the compound mid-afternoon after detonating a car bomb at the entrance, sending terrifying government workers running for their lives. Some jumped from the windows.
Hundreds more were trapped inside buildings as security forces swarmed the area, engaging in a fierce gun battle with the attackers.
TRT World's Bilal Sarwary reports from Kabul.
Four attackers killed
Afghan forces killed three of the attackers and freed more than 300 people trapped inside the compound, Rahimi said. A fourth attacker died in the car bomb explosion.
One of the wounded civilians broke several bones after jumping from the third floor of a building to escape the attackers, an AFP correspondent at a hospital said.
Another two were wounded by broken glass.
No claim of responsibility
There was no immediate claim of responsibility for the raid, which began mid-afternoon with a bomb-laden vehicle exploding at the entrance.
That was followed by a second blast, interior ministry spokesman Najib Danish said, though he did not specify its nature.
Plumes of black smoke could be seen rising from the compound, with at least two military helicopters circling above.
Journalists near the scene reported hearing numerous explosions in the hours after the attack began.
Ashraf, a witness who works at the Ministry of Public Works and who goes by one name, said militants inside the compound exchanged gunfire with security forces.
The assault comes a day after President Ashraf Ghani appointed Amrullah Saleh and Assadullah Khaled, both former spymasters known for their anti-Taliban and Pakistan stance, to head the interior and defence ministries, respectively.
Militants have previously attacked government ministries and departments because they are often poorly defended and seen as soft targets.
Monday's attack was the biggest in Kabul since November 28 when the Taliban detonated a vehicle bomb outside the compound of British security firm G4S, killing at least 10 people and leaving a massive crater in the road.
While there has been no official announcement of a US drawdown, the mere suggestion of the United States reducing its military presence has rattled the Afghan capital and potentially undermined peace efforts.
General Scott Miller, the top US and NATO commander in Afghanistan, said on Sunday he had not received orders to pull forces out of the country.
Trump's decision apparently came Tuesday as US peace envoy Zalmay Khalilzad met with the Taliban in Abu Dhabi, part o f efforts to bring the militants to the negotiating table with Kabul.
Many Afghans are worried that President Ashraf Ghani's fragile unity government would collapse if US troops pulled out, enabling the Taliban to return to power and potentially sparking another bloody civil war.