Bulugh al-Maram 595
وَعَنْ ابْنِ عَبَّاسٍ رَضِيَ اللَّهُ عَنْهُمَا قَالَ: مَرَّ رَسُولُ اللَّهِ - صلى الله عليه وسلم - بِقُبُورِ الْمَدِينَةِ, فَأَقْبَلَ عَلَيْهِمْ بِوَجْهِهِ فَقَالَ: «السَّلَامُ عَلَيْكُمْ يَا أَهْلَ الْقُبُورِ, يَغْفِرُ اللَّهُ لَنَا وَلَكُمْ, أَنْتُمْ سَلَفُنَا وَنَحْنُ بِالْأَثَرِ». رَوَاهُ التِّرْمِذِيُّ, وَقَالَ: حَسَنٌ.
Ibn ʿAbbas, may Allah be pleased with them both, said: The Messenger of Allah ﷺ passed by the graves of Madinah, turned his face towards them and said: "Peace be upon you, O people of the graves. May Allah forgive us and you. You have gone before us, and we are following." Reported by at-Tirmidhi, who said: hasan.