A black woman, or perhaps a young man, used to sweep the mosque. The Messenger of Allah ﷺ noticed her absence and asked about her, or about him. The people said, "She has died."He asked, "Why did you not inform me?"It seemed they had considered the matter too trivial to mention. So he said, "Show me her grave."They showed him, and he prayed over her. Then he said, "These graves are filled with darkness for their occupants, and Allah illuminates them through my prayer over them."
أن امرأة سوداء كانت تقم المسجد (أو شابا) ففقدها رسول الله ﷺ فسأل عنها (أو عنه) فقالوا: مات. قال: أفلا كنتم آذنتموني قال: فكأنهم صغروا أمرها (أو أمره) فقال: دلوني على قبره فدلوه فصلى عليها، ثم قال: إن هذه القبور مملؤة ظلمة على أهلها، وإن الله عز وجل ينورها لهم بصلاتي عليهم.
Bukhari related it in the Book of Funerals (1337), and Muslim in the Book of Funerals (956), both from the hadith of Hammad bin Zayd, from Thabit Bunani, from Abu Rafi, from Abu Hurairah, and he mentioned it. The wording is Muslim's, and Bukhari's wording is close to it.The scholars determined that this grave belonged to a woman, because some narrations state this without any doubt, and certainty takes precedence over doubt. As for his saying, "sweep the masjid," this means to clean it, qumamah being the sweepings, and the miqammah being the broom.The majority of scholars adopted this hadith and held that it is permissible to pray over the deceased after burial. Malik, Abu Hanifa, and others prohibited it, arguing that this was among the special privileges of the Prophet ﷺ, and that Allah illuminates the grave of the deceased through his prayer over it, as the Chosen One informed.For more, see Minna Kubra (3/68).