Several gunmen remained holed up inside the building for over six hours before being killed by security forces, said Nasrat Rahimi, the interior ministry spokesman. The attackers' potential target, vice-presidential candidate and former intelligence chief Amrullah Saleh, was "evacuated from the building and moved to a safe location," Rahimi said. Some 85 other civilians were also rescued from inside.
At least two gunmen were trapped for hours in the top floor of the four-story building, exchanging fire with security forces, he said. Three other attackers were killed in the fighting. President Ashraf Ghani tweeted that Saleh was unharmed during the "complex attack" targeting the Green Trend party headquarters.
One civilian woman was among those killed in the attack, said Wahidullah Mayar, the health ministry spokesman. Ferdous Faramarz, the spokesman for Kabul's police chief, said the explosion was likely a suicide car bomb.
The blast was large enough to be heard throughout the capital. No one immediately claimed responsibility for the attack, but both Taliban insurgents and the Islamic State group are active in the capital and have carried out attacks there in the past.
President Ghani is seeking a second term in the Sept. 28 election on promises of ending the 18-year war but has been largely sidelined over the past year as the U.S. has negotiated directly with the Taliban, who view the Kabul government as an American puppet.
The Taliban effectively control around half the country and have continued to carry out daily attacks on Afghan security forces. Earlier Sunday, a Taliban suicide bomber killed four police officers in an attack on a police station in the eastern Ghazni province, according to Ahmad Khan Serat, a spokesman for the provincial police.
U.S. envoy Zalmay Khalilzad, who is currently visiting Kabul, has held several rounds of talks with the Taliban in recent months in a bid to end America's longest war. The two sides appear to be closing in on an agreement in which the U.S. would withdraw its forces in return for a pledge from the Taliban to keep the country from being used as a launch pad for global attacks.
The Taliban and the Islamic State group's affiliate in Afghanistan are sharply divided over ideology and tactics, with the Taliban largely confining their attacks to government targets and Afghan and international security forces.
The Taliban and IS have fought each other on a number of occasions, and the Taliban are still the larger and more imposing force.