Hadithcore
Riyad as-Salihin, 580

Buraidah (May Allah be pleased with him) reported:

Messenger of Allah (ﷺ) said, "(In the past) I forbade you from visiting graves, but visit them now." In another narration Messenger of Allah (ﷺ) said, "Whoever wants to visit a graveyard, let him do so, because it reminds us of the Hereafter." <b>[Muslim].</b>

عن بريدة رضي الله عنه قال قال رسول الله صلى الله عليه وسلم ‏"‏كنت نهيتكم عن زيارة القبور فزوروها‏"‏ ‏(‏‏(‏رواه مسلم‏)‏‏)‏‏.‏ وفي رواية ‏"‏فمن أراد أن يزور القبور فليزر؛ فإنها تذكرنا الآخرة ‏"‏

References1 variant
In-Book Reference
Introduction, Hadith 580
Sharh · explanationclick to expand
<b>Guidance from the Hadith:</b><br> 1) The wisdom behind the initial forbiddance of visiting the graves was to protect people from committing Shirk (associating partners with Allah). This is because people at that time were new converts to Islam. So, the ban was intended to protect their state of monotheism. Belief was not yet ingrained into their hearts, so it was feared that they might commit acts of Shirk, such as asking the dead to help them or fulfill their needs. Those acts frustrate one’s good deeds and are a cause for entering Hellfire.<br> 2) Then visiting the graves was sanctioned for the benefits it has to the visitor and the visited. The visitor takes lessons as he remembers death and the Hereafter; whereas the visited benefits from the supplication made for him, not to him. It behooves us to correct our monotheistic beliefs.
Related hadiths2
Compare isnād across 2 related chains →