A suicide bomber detonated explosives inside a Shiite mosque on the southwestern fringe of the capital, killing 39 people - among them women and children - on a day in Afghanistan reserved for prayer and reflection.