Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bayhaqi:7206[Chain 1] Abū al-Ḥusayn b. Bishrān > Abū Jaʿfar al-Razzāz > Jaʿfar b. Muḥammad b. Shākir > ʿAffān > Hammām And ʿAbd al-Wārith > Muḥammad b. Juḥādah > Abū Ṣāliḥ > Ibn ʿAbbās [Chain 2] Abū Bakr b. Fūrak > ʿAbdullāh b. Jaʿfar > Yūnus b. Ḥabīb > Abū Dāwud al-Ṭayālisī > Shuʿbah > Muḥammad b. Juḥādah

[Machine] The Messenger of Allah ﷺ cursed those who visit graves and build mosques and lights on them. The wording of the hadith is from Shu'ba, and in their narration it is "the visitors of graves and those who build mosques and lights on them".  

البيهقي:٧٢٠٦أَخْبَرَنَا أَبُو الْحُسَيْنِ بْنُ بِشْرَانَ أنبأ أَبُو جَعْفَرٍ الرَّزَّازُ ثنا جَعْفَرُ بْنُ مُحَمَّدِ بْنِ شَاكِرٍ ثنا عَفَّانُ ثنا هَمَّامٌ وَعَبْدُ الْوَارِثِ عَنْ مُحَمَّدِ بْنِ جُحَادَةَ عَنْ أَبِي صَالِحٍ عَنِ ابْنِ عَبَّاسٍ ح وَأَخْبَرَنَا أَبُو بَكْرِ بْنِ فُورَكٍ قَالَ أنبأ عَبْدُ اللهِ بْنُ جَعْفَرٍ ثنا يُونُسُ بْنُ حَبِيبٍ ثنا أَبُو دَاوُدَ الطَّيَالِسِيُّ ثنا شُعْبَةُ عَنْ مُحَمَّدِ بْنِ جُحَادَةَ قَالَ سَمِعْتُ أَبَا صَالِحٍ وَقَدْ كَانَ كَبِرَ عَنِ ابْنِ عَبَّاسٍ قَالَ

لَعَنَ رَسُولُ اللهِ ﷺ زَائِرَاتِ الْقُبُورِ وَالْمُتَّخِذَاتِ عَلَيْهَا الْمَسَاجِدَ وَالسُّرُجَ لَفْظُ حَدِيثِ شُعْبَةَ وَفِي رِوَايَتِهِمَا زَوَّارَاتِ الْقُبُورِ وَالْمُتَّخِذِينَ عَلَيْهَا الْمَسَاجِدَ وَالسُّرُجَ