Whoever pays a visit to a grave should face the deceased, greet him, and supplicate for him. On this subject we find the following: Buraidah reported: “The Prophet, peace be upon him, taught us that when we visited graves we should say, ‘Peace be upon you, O believing men and women, O dwellers of this place. Certainly, Allah willing, we will join you. You have preceded us and we are to follow you. We supplicate to Allah to grant us and you security’.” (Reported by Muslim, Ahmad, and others)
Ibn ‘Abbas reported: “Once the Prophet, peace be upon him, passed by graves in Madinah. He turned his face toward them saying: ‘Peace be upon you, O dwellers of these graves. May Allah forgive us and you. You have preceded us, and we are following your trail’.” (Tirmizhi)
‘Aishah said: “Every time it was my turn to be with the Prophet, peace be upon him, toward the end of the night, he would go out to the cemetery of al-Baqi’ and would say,
‘Peace be upon you, O abode of believers. What you were promised will come to pass tomorrow at a fixed time. We shall, Allah willing, soon join you. O Allah! Grant forgiveness to the people who are buried in al-Baqi’ al-Gharqad’,’ (Muslim)
‘Aishah also reported: “I asked: ‘What should I say when I pass by a graveyard, O Messenger of Allah?’ He replied, ‘Say, “Peace be upon the believing men and women dwelling here. May Allah grant mercy to those who have preceded us and those who are to follow them. Certainly, Allah willing, we will join you”‘.”
What some people do, like wiping hands over the graves and tombs, kissing them, and circumambulating around them are abominable innovations. Such things should not be done, for they are unlawful. These things are permissible, however, if performed in relation with the House of Allah, the Ka’abah, for Allah has so honored it. The grave of the Prophet, peace be upon him, cannot be considered a similar case, nor the tomb of a saint. All good comes from adherence to his example whereas all evil flows from innovating new things in religion.
Ibn al-Qayyim said: “The Prophet, peace be upon him, visited the graves to supplicate for their inhabitants, and to seek mercy and forgiveness of Allah for them. Contrary to this, the pagans supplicated to the dead, swearing by them, asking them for their needs, and seeking their support and help. Such pagan practices are in conflict with the guidance of the Prophet, peace be upon him, and his teachings about the Oneness of Allah and about the manner of supplicating for Allah’s mercy for the dead. The people who do such things are guilty of polytheism; they are indulging in sin, and bringing evil to the deceased. They may be divided into three categories: those who supplicate for the deceased, those who supplicate through the deceased, and the third who supplicate to the deceased. They think that making supplications by a grave is better than in a mosque. For anyone who looks to the guidance of the Messenger of Allah, peace be upon him, and his Companions, the distinction between the two cited positions is fairly obvious.”