The number of bomb blasts and suicide attacks has reduced dramatically since the Taliban ended their insurgency after seizing power in August 2021, ousting the US-backed government.
However, a number of armed groups -- including the regional chapter of the Islamic State organisation -- remain a threat.
There was no immediate claim of responsibility for the blast, which rang out as Shiite worshippers gathered for Friday prayers at the Imam Zaman mosque in Pol-i-Khomri, the capital of Baghlan province.
"Security and investigative forces went to the area of the incident to investigate how this heartbreaking incident happened," said provincial information and media chief Mustafa Asadullah Hashimi.
"Investigations are still ongoing," he said in a statement confirming the casualties.
A source at Baghlan Provincial Hospital -- who asked to remain anonymous -- put the tally higher, saying 19 bodies and 40 wounded patients had been brought to the facility so far.
"Some of the dead and wounded were taken to other private hospitals as well," he told AFP.
Local resident Abdul Hamid said he heard a "terrible sound" as the bomb detonated.
"After the explosion, a large number of martyrs and injured people were transferred to the hospital," he said. "The situation is not good at all."
Another local said security forces were ushering people away from the area.
One resident who feared his father and brother were in the blast zone was struggling to find out their fate.
"The situation around the hospital is very bad. Everyone is trying to find their family members but no one is allowed to go inside the hospital," he told AFP, also speaking anonymously.
The regional chapter of the Islamic State (IS) group has in the past targeted Shiites they consider heretics.
The Taliban and IS share an austere Sunni ideology, however, Kabul's new rulers have pledged to protect ethnic and religious minorities.
IS is also crusading to establish a global "caliphate" -- Islamic empire -- instead of the Taliban's more modest goal of ruling an independent Afghanistan with formal ties to other countries.
Since the Taliban returned to government IS has staged attacks on diplomatic missions in Kabul, and ministry buildings, as well as assassinated two provincial governors.
They are also blamed for the September 2022 bombing of a study hall in a minority Shiite neighbourhood of the capital, killing at least 53 people -- including 46 girls and young women -- according to the United Nations.
IS seeks to "provoke sectarian conflict and destabilise the region" and since 2022 has conducted more than 190 suicide bombings, leaving some 1,300 injured or dead, a UN Security Council report said in May.
The presence of IS fighters in Afghanistan has also stoked tensions with neighbouring Pakistan, which claims they are crossing the border to strike targets on its soi