Video footage showed bodies surrounded by debris inside the mosque that is used by people from the minority Shi'ite Muslim community.
No group immediately claimed responsibility. The blast follows several attacks, including one at a mosque in Kabul, in recent weeks, some of which have been claimed by the Sunni Muslim militants of Islamic State.
The attacks have underscored security challenges for the Taliban, which took over the country in August and have since carried out operations against Islamic State cells in Kabul.
"This afternoon, an explosion took place in a mosque of our Shiite compatriots ... as a result of which a number of our compatriots were martyred and wounded," Taliban spokesman Zabihullah Mujahid said on Twitter.
Bakhtar news agency, run by the ministry of information, said 46 people were killed and 143 wounded in the blast.
More about: Afghanistan