In his Sunan al-Sughra he does cite it, whereas in al-Dhakhaʾir he attributes it only to Muslim.
There are additional narrations on this subject from ʿĀʾishah and Ibn ʿAbbās together, from Abū Hurayrah, and from Ibn Masʿūd—their ḥadith were quoted a little earlier—and also from Ibn ʿAbbās in the wording:
“The Messenger of Allah ﷺ cursed women who visit graves and those who turn them into places of worship and set up lamps over them.”
It is reported by the Four compilers except Ibn Mājah, as well as by al-Ḥākim, al-Bayhaqī, al-Ṭayālisī, and Aḥmad. In this precise wording the report is weak, except for the first clause, which is authentic because it is transmitted by another chain through Abū Hurayrah and Ḥassān ibn Thābit. I have treated this issue in detail in al-Taʿlīqāt al-Jiyād in a manner not found elsewhere—praise be to Allah.
Know that the first ḥadith establishes the prohibition of building mosques over graves, which, all the more so, entails the prohibition of praying in them. As is obvious, this falls under the principle of blocking the means: the act of construction is forbidden so that the ultimate objective—worship in a building erected in disobedience to Allah Most High—does not materialise, together with the doctrinal corruptions that inevitably follow, as reality bears out.
The second ḥadith is more comprehensive than the first, for its wording covers both the means and the end: regarding a place as a mosque means praying in it (1), and it also signifies building upon it from