Islamic State gunmen opened fire on a ceremony in Kabul, killing 32 people in the first major attack in the city since the US reached an agreement with the Afghan Taliban on a phased withdrawal of troops.
Top Afghan political leader, Abdullah Abdullah, was present with other key political figures and escaped unharmed.
Eighty-one people were wounded, a government spokesman said, adding the death toll could rise.
Islamic State claimed responsibility for the attack, the group’s Amaq news agency reported on its telegram channel.
The Taliban, ousted from power by US-led troops in 2001, denied involvement.
The gathering marked the 25th anniversary of the death of Abdul Ali Mazari, an ethnic Hazara leader killed in 1995 after being taken prisoner by the Taliban.
Several people were killed in a similar attack at the same commemoration last year, which Islamic State said was carried out by its militants.
“The attack started with a boom, apparently a rocket landed in the area, Abdullah and other politicians escaped unhurt,” Abdullah’s spokesman, Fraidoon Kwazoon, told Reuters.
Broadcaster Tolo News showed live footage of people running for cover as gunfire was heard.
Afghan defence forces continued to fight gunmen throughout the day, securing the area when killing three gunmen in the late afternoon, according to ministry of interior spokesman Nasrat Rahimi.
President Ashraf Ghani tweeted the attack was “a crime against humanity and the national unity of Afghanistan”.
Abdullah was runner-up in the last three Afghan presidential elections, each of which he disputed. He served as chief executive of a coalition government since 2014 and is a former foreign minister.
Ghani telephoned Abdullah, his long-time political rival. Abdullah is contesting an Electoral Commission announcement last month declaring Ghani winner of September’s presidential election.
Relatives gathered at the morgue of a hospital not far from the blast, with many breaking down in tears as they waited to identify loved ones.
Ambulances and stretchers bustled back and forth at the hospital delivering the wounded for treatment.
“I was at the ceremony when gunshots started. I rushed to the door to get away but my foot was hit by a bullet,” Mukhtar Jan told Reuters from a stretcher at the hospital.
Ali Attayee, at hospital to support his wounded brother, said: “Those who committed this want to destroy our people. We’re sorry for those committing such crimes.”
Representatives of the US, EU and NATO condemned the attack.
“Attacking the innocent and defenceless at a memorial event is a sign of weakness, not a show of strength. The Afghan people deserve a future free from terror,” US Secretary of State Mike Pompeo said in a statement.
The attack was one of the largest on civilians in Afghanistan in a year.
“Horrific attack in Kabul today. Heartbreaking and unacceptable. We are tired of war and violence,” said Shahrzad Akbar, head of the Afghanistan Independent Human Rights Commission.
Hazaras are mostly Shi’ite Muslims. Minority Shi’ites are repeatedly attacked by Sunni militants in Afghanistan.
The US seeks to spearhead efforts toward a lasting peace arrangement. Violence decreased during a seven day hold down accord with the Taliban before last Saturday’s deal with the Taliban resuming attacks on Afghan forces.