The death toll from an attack Sunday against the Kabul office of the Afghan president's running mate and former chief of the intelligence service has left at least 20 people dead, an official said Monday.

Some 50 other people were wounded in the attack against the Green Trend party headquarters.

It lasted hours and included a gunbattle between security forces and the attackers, who were holed up inside the building, according to Interior Ministry spokesman Nasrat Rahimi.

Several gunmen were killed by security forces, Rahimi said.

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.

No one immediately claimed responsibility for the attack, but both the Taliban and the Islamic State in Iraq and Syria (ISIS) have carried out large-scale attacks in Kabul in the past.

The Taliban, who effectively control half the country at this point, have also been staging near-daily attacks across Afghanistan even as they hold talks with the U.S. about a peaceful resolution to the 18-year war. The insurgents however, refuse to directly negotiate with the government, considering it a U.S. puppet.

Afghan security forces stand guard at the site of the attack. (Rahmat Gul/The Associated Press)

Sunday marked the first day of the Afghan presidential campaign, with a vote scheduled for the end of September.

President Ashraf Ghani tweeted Saleh was unharmed during the "complex attack" targeting the Green Trend office.

Saleh founded the Green Trend after he was sacked as intelligence chief in 2010 by former president Hamid Karzai. Though a relative newcomer on the Afghan political scene, its focus has been democracy and reform while fiercely opposing the Taliban and its extremist ideology.

Started with suicide car bomb

Ferdous Faramarz, spokesperson for Kabul's police chief, said the attack started with a suicide car bombing, and then other attackers entered the building and started shooting at security forces.

The explosion from the initial bombing was large enough to be heard throughout the capital.

Ghani is seeking a second term in the Sept. 28 vote on promises of ending the war, but has been largely sidelined over the past year amid U.S.-Taliban talks.

U.S. envoy Zalmay Khalilzad, who is currently visiting Kabul, has held several rounds of talks with the Taliban in recent months. 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 ISIS are sharply divided over ideology and tactics. The Taliban largely confines attacks to government targets and Afghan and international security forces, while ISIS militants mainly target the country's minority Shias.

The Taliban and ISIS have fought each other on a number of occasions, and the Taliban are still the larger and more imposing force.