Hadith # 581
Buraidah (May Allah be pleased with him) reported: Messenger of Allah (PBUH) said, "(In the past) I forbade you from visiting graves, but visit them now." In another narration Messenger of Allah (PBUH) said, "Whoever wants to visit a graveyard, let him do so, because it reminds us of the Hereafter."
[Muslim]
Commentary
The visit to the graves is not only recommendable from a theological point of view but, in the light of the Prophetic saying, it is also compulsory and binding. However, at the dawn of Islam it was forbidden due to the apprehension that the Muslims might relapse into some wrongdoing by harking back to the pre-Islamic memory. But when the Monotheistic Belief took root in their minds and the apprehension of pagan echoings evaporated, the ban on visiting the graves was lifted. Rather an emphasis was laid on such a visit, so that an overpowering thought of death might penetrate a believer's mind as a deterrent force against the promptings of his animal self. The believers must remember death and remember that they will be dead sooner or later. It has been reported that 'Umar bin Al-Khattab(May Allah be pleased with him) used to address himself thus: "Death suffices to serve as an admonitor, O 'Umar!"
Top