Gunmen opened fire on Friday at a ceremony in Afghanistan’s capital attended by prominent political leaders, killing at least 32 people and wounding dozens more before the two attackers were killed by police, officials said.

The Islamic State group claimed responsibility for the attack in a statement on its website.

Militants from Isis have declared war on Afghanistan’s Shias, and many of those at the ceremony were from the minority sect. The ceremony commemorated the 1995 slaying of Abdul Ali Mazari, the leader of Afghanistan’s ethnic Hazaras, who are mostly Shia Muslims.

The Taliban said they were not involved in the attack, which came less than a week after the US and the group signed an ambitious peace deal that lays out a path for the withdrawal of American forces from the country.

The interior ministry spokesman Nasrat Rahimi said 32 people were killed and 81 wounded in the attack in the Dasht-e-Barchi neighborhood of Kabul. The health ministry gave the same death toll but said 58 were wounded. All of the casualties were civilians, Rahimi said.

The opposition leader Abdullah Abdullah, who is the country’s chief executive and was a candidate in last year’s presidential election, was among several prominent political officials who attended the ceremony but left before the attack.

Several TV journalists were covering the ceremony inside a walled compound when the gunmen began shooting, and a reporter and a cameraman for a local broadcaster were among the wounded.

Karim Khalili, the chief of Afghanistan’s high peace council, was delivering a speech when the gunfire interrupted him. He was not hurt and later went on TV to denounce the violence.

Several witnesses said that, amid the panic, members of the security forces at the event had fired on civilians in the crowd. “Individuals with military uniforms who were there targeted people, there were casualties, dead and wounded, said Ghulam Mohammad, a witness, according to Associated Press video.

Another survivor, Noor Mohammad, said: “Everyone was running. Three casualties were on the ground in front of me. I ran out of there to save my life.”

After opening fire, the two gunmen fled to a half-finished apartment building, leading to a five-hour standoff with security forces. They were eventually killed and security forces cleared the building, Rahimi said. The area was cordoned off by dozens of security forces.

The Islamic State group claimed responsibility for the deadliest attack in Kabul last year, when a suicide bomber killed 63 people and wounded 182 at a wedding. All were from the Shia Hazara community.

Any US troop withdrawal from Afghanistan would be tied to promises by the Taliban to fight terrorism and Isis. During the withdrawal, the US would retain the right to continue counter-terrorism operations in the country.

The Taliban have been fighting Islamic State militants in its headquarters in eastern Afghanistan. US military officials have said Isis has been degraded because of US and Afghan operations but also by Taliban assaults. A US defence department official told the AP that there was concern that Isis was expanding its footprint into Kunar province, where the Taliban knows the terrain and could be an asset in tracking down Isis.