Riyad as-Salihin

Riyad as-Salihin 583

Desirability of visiting the Graves for men, and that they should say
Arabic hadith text
وعن ابن عباس رضي الله عنهما، قال مر رسول الله صلى الله عليه وسلم بقبور بالمدينة فأقبل عليهم بوجهه فقال‏:‏ “السلام عليكم يا أهل القبور، يغفر الله لنا ولكم أنتم سلفنا ونحن بالأثر” ‏(‏‏(‏رواه الترمذي وقال‏:‏ حديث حسن‏)‏‏)‏‏.‏
Translation
Ibn 'Abbas (May Allah be pleased with them) reported

Messenger of Allah (ﷺ) passed by the graves at Al-Madinah. He turned his face towards them and said, "May you be granted safety, O inmates of the graves. May Allah forgive us and you. You have preceded us, and we are to follow."[At-Tirmidhi, who classified it as Hadith Hasan].