At least 17 people died and 20 people were injured in an explosion in a mosque in Afghanistan's Baghlan province, local media reported on Friday.