People run away after a bomb explosion during Fatiha prayers at the Nabawi mosque in the Hesa-e-Awal area of Fayzabad district, Badakhshan province on June 8, 2023. AFP
Security has improved dramatically since the Taliban stormed back to power in August 2021, ousting the US-backed government and ending their two-decade insurgency, but the Islamic State group remains a threat.
An interior ministry statement said the blast at the funeral for the acting governor of northeastern Badakhshan province also injured more than 30 people as "a great number of compatriots" gathered for a mosque service honouring Nisar Ahmad Ahmadi.
"The Ministry of Interior of the IEA condemns this brutality of the disgraced enemies," a statement said of the explosion in the provincial capital of Faizabad.
"I was standing outside the mosque to receive the guests coming, suddenly a terrible sound shook the mosque," said witness Naseer Ahmad.
"When I entered the mosque, I saw bloodied dead bodies laying on the ground," the 37-year-old told AFP.
An AFP journalist near the scene of the blast said Taliban government security forces had set up checkpoints around the funeral site in the morning.
When the explosion rang out people fled into nearby streets, and shops closed in panic as security forces cordoned off the area.
The AFP reporter saw 10 bodies on stretchers at a local hospital.
IS claimed responsibility for Ahmadi's killing on Tuesday, when a suicide bomber drove a car filled with explosives into his vehicle.
The driver was also killed and six others were wounded in that attack, which also took place in Faizabad.
The United Nations Assistance Mission in Afghanistan (UNAMA) said on Twitter it "unequivocally condemns this and a recent spate of appalling and indiscriminate attacks that have shown a total disregard for civilian lives".
The Taliban and IS share an austere Islamist ideology but the latter have a more ambitious goal of establishing a global "caliphate".
IS has emerged as the biggest security threat to the Taliban rulers of Afghanistan, who have pledged to prevent the nation from serving as a staging ground for international attacks.
IS has claimed responsibility for attacks on minority religious groups, foreign embassies as well as Taliban government officials.