The interior ministry following a statement said the incident took place inside a mosque in Deh Yak district on Saturday.
The statement by interior ministry further added that the explosion left seven militants dead and there were no other casualties.
Interior ministry condemned the anti-government militant groups for using religious places for conducting terrorist activities and said such activities show that the militant groups are acting against the principles of Islam.
The anti-government militant groups including the Taliban militants frequently use improvised explosive device (IED) as the weapon of their choice to target Afghan and coalition security forces, however innocent civilians are mostly targeted in such attacks.
The United Nations in its latest report earlier last month also said that the improvised explosive device (IEDs) planted by anti-government armed militant groups, were the major contributor to civilian casualties in Afghanistan.
UN in its report said the anti-government armed militant groups were responsible for 34 percent of all civilian casualties which were caused due to improvised explosive device (IEDs).