Interior Ministry spokesman Nasrat Rahimi said 32 people were killed and 81 wounded in the attack in the Dasht-e-Barchi neighbourhood of Kabul.
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 slain by police, officials said.
Daesh claimed responsibility for the attack on its website. Afghanistan's upstart Daesh affiliate has declared war on the country's minority Shias. Many of those at the ceremony were Shias because it was commemorating the 1995 slaying of Abdul Ali Mazari, the leader of Afghanistan's ethnic Hazaras, who are mostly Shia.
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.
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 also reported 32 people were killed but said 58 were wounded.
A Health Ministry spokesman said the casualty toll could rise.
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 guarding 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 were clearing the building, Rahimi said.
The area was cordoned off by dozens of security forces.
All of the casualties were civilians, Rahimi said.
President Ashraf Ghani tweeted that the attack was "a crime against humanity and against the national unity of Afghanistan."
Daesh 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 pullout from Afghanistan would be tied in part to promises by the Taliban to fight terrorism and Daesh. During the withdrawal, the US would retain the right to continue its counterterrorism operations in the country.
The Taliban have been fighting Daesh militants in its headquarters in eastern Afghanistan.
US military officials have said Daesh has been degraded because of US and Afghan operations but also by Taliban assaults. A US Defense Department official told the AP that they worried Daesh was expanding its footprint into Kunar province, where the Taliban knows the terrain and could be an asset in tracking down Daesh.