KABUL — Presidential running mate Amrullah Saleh barely escaped with his life Sunday when a suicide bomber and squad of gunmen besieged his office in the Afghan capital, his aides said Monday. The attack left 20 people dead, 50 injured and much of the five-story concrete building reduced to rubble.

Saleh, 48, a former national intelligence chief, is President Ashraf Ghani’s pick for first vice president in his bid to win a second five-year term. The two appeared Sunday at a boisterous opening campaign rally, and Saleh was meeting afterward with supporters and aides when a vehicle full of explosives detonated outside his political party compound.

According to his aides, Saleh sprinted up the stairs onto the roof and clambered across a ladder to the adjacent building, escaping with a slight wound to one arm, while security forces shot downward from the roof as a half-dozen gunmen invaded the building and began shooting people on sight.

On Monday, one of Saleh’s aides took journalists to the roof, pointing to the spot where he and a number of others had climbed to safety next door.

No group has claimed the attack, but Saleh is a longtime, high-profile adversary of Taliban insurgents. He is popular with the Afghan public and was a close associate of Ahmad Shah Massoud, the legendary anti-Soviet and anti-Taliban militia leader who was assassinated in 2001.

In a tweet Sunday evening, Ghani wrote that the attack was carried out by “enemies of the state.”

Zalmay Khalilzad, the top U.S. negotiator in peace talks with the Taliban, tweeted Monday that the attack was a “grotesque and clear act of terrorism.”

Security forces battled the attackers for six hours, while scores of Saleh’s close associates and guests were trapped inside the building. Some were shot on sight, and others hid in bathrooms or closets. Security officials said they eventually shot dead four of the attackers and evacuated more than 150 people from the premises. 

On Monday, the official death toll rose from two to 20, and aides to Saleh said they included civilians and security forces. Journalists touring the compound saw rooms filled with rubble on every level, bloodstained floors, shattered windows and overturned furniture. There were portraits of Massoud in many rooms.

Outside were several vehicles that had become heaps of twisted, charred metal. One was the suicide vehicle, Saleh’s aides said. Another was an SUV that may have belonged to a guest who had tried to follow him up the stairs but was intercepted and shot dead. The man was not immediately identified. 

The insurgents have unleashed a spate of violent attacks in recent months while conducting intermittent peace talks with U.S. officials. Some experts have suggested the election, now slated for Sept. 28 after two delays, should be postponed once more because of fears of violence against voters and candidates. But Ghani reiterated Sunday that he was determined to hold the election as planned.

Saleh, who heads a political party called Green Trend, was once a tough critic of Ghani for failing to bring better security to the war-torn nation. Last fall, however, the president named him interior minister and then asked him to become his first vice president along with two other running mates. 

Ghani and Abdullah Abdullah, the government’s chief executive who is also running for president, visited Saleh at his home Monday.

Saleh has not spoken publicly since the attack, but photos circulating on social media late Sunday and Monday showed him sitting on the grass after being taken to a safe location, surrounded by gunmen, with his right arm bleeding through a bandage and a grim expression on his face.