Hadithcore
Mishkat al-Masabih, 1765

Ibn 'Abbas said that when God's messenger passed by some graves in Medina he turned his face towards them and said, “Peace be upon you, inhabitants of the graves. God forgive us and you. You have gone before us and we are coming after.” Tirmidhi transmitted it saying this is a <i>hasan gharib</i> tradition.

عَنِ ابْنِ عَبَّاسٍ قَالَ: مَرَّ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ بِقُبُورٍ بِالْمَدِينَةِ فَأَقْبَلَ عَلَيْهِمْ بِوَجْهِهِ فَقَالَ: «السَّلَامُ عَلَيْكُمْ يَا أَهْلَ الْقُبُورِ يَغْفِرُ اللَّهُ لَنَا وَلَكُمْ أَنْتُمْ سَلَفُنَا وَنَحْنُ بِالْأَثَرِ» . رَوَاهُ التِّرْمِذِيُّ وَقَالَ: هَذَا حَدِيثٌ حَسَنٌ غَرِيبٌ

References1 variant
In-Book Reference
Book 5, Hadith 237