KABUL -- Gunmen opened fire 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 slain 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 Shiites, and many of those at the ceremony were from the minority Shiite sect. The ceremony commemorated the 1995 slaying of Abdul Ali Mazari, the leader of Afghanistan's ethnic Hazaras, who are mostly Shiite Muslims.
The Taliban said they were not involved in the attack, which came less than a week after the U.S. and the group signed an ambitious peace deal that lays out a path for the withdrawal of American forces from the country.
Interior Ministry spokesman Nasrat Rahimi said 32 people were killed and 81 wounded in the attack in the Dasht-e-Barchi neighbourhood of Kabul. The Health Ministry gave the same death toll but said 58 were wounded. All of the casualties were civilians, Rahimi said.
Opposition leader Abdullah Abdullah, who is the country's chief executive and was a top contender in last year's presidential election, was among several prominent political officials who attended the ceremony but left before the attack and were unhurt.
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 witness Ghulam Mohammad, 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 holed up in 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 Shiite Hazara community.
Any U.S. troop pullout from Afghanistan would be tied in part to promises by the Taliban to fight terrorism and IS. During the withdrawal, the U.S. would retain the right to continue its counter-terrorism operations in the country.
The Taliban have been fighting Islamic State militants in its headquarters in eastern Afghanistan. U.S. military officials have said IS has been degraded because of U.S. and Afghan operations but also by Taliban assaults. A U.S. Defence Department official told the AP that they worried IS was expanding its footprint into Kunar province, where the Taliban knows the terrain and could be an asset in tracking down ISIS.