Short answer
You may visit the graves of the righteous, greet them, pray for them and make dua to Allah for yourself there. What is not allowed is asking the person in the grave to fulfil your needs, prostrating to the grave, circling it, or making vows to it. Scholars differ on choosing a grave as a special place for your own dua.
Visiting graves is mustahabb for men, with greeting, recitation and dua for the dead. Making dua to Allah alone at the grave of a righteous person is permissible according to many Hanafi scholars; directing the dua to the buried person, prostrating, kissing or circling the grave, lighting lamps on it and vowing to it are not allowed.
The four schools agree on this.
Explanation
The Prophet ﷺ said: "I had forbidden you from visiting graves, but now visit them," and he taught his Companions to greet the dead with "Peace be upon you, people of these dwellings, believers and Muslims." Visiting a grave to remember death and pray for the dead is a sunnah, and the graves of scholars and righteous people are included.
Many Hanafi scholars allow you, after praying for the deceased, to make dua to Allah for your own needs there, hoping for His mercy in a place connected to a righteous servant. The dua is still to Allah, and the person in the grave does not grant it. Other scholars hold that choosing a grave as a special place for one's own dua is an innovation, pointing to the warning against taking graves as places of worship. Scholars across the schools agree on the following limits:
- Do not ask the buried person to cure, provide or forgive: that is asking someone other than Allah (72:18).
- Do not prostrate to the grave, pray facing it, walk around it in worship, or kiss it.
- Do not make vows (nadhr) to the person in the grave or offer animals to them.
- Do not sit on graves or build places of worship over them.
A simple way: give the greeting, recite al-Fatiha or al-Ikhlas and give its reward to the deceased, make dua for them, then turn toward the qibla and ask Allah for yourself. See the dua for visiting the grave and tawassul. Women visiting graves is answered in the women section, and more on graves in the death section.
The evidence
Quran, Surah Al-Jinn 72:18
وَأَنَّ ٱلْمَسَٰجِدَ لِلَّهِ فَلَا تَدْعُوا۟ مَعَ ٱللَّهِ أَحَدًۭا ﴿١٨﴾
And [He revealed] that the masjids are for Allah, so do not invoke with Allah anyone.
Dua belongs to Allah alone, wherever it is made.
Sahih Muslim 977
Sahih... نهيتكم عن زيارة القبور فزوروها ...
"I had forbidden you from visiting graves, so now visit them."
Visiting graves is allowed and encouraged.
Sahih Muslim 975
Sahih... السلام عليكم أهل الديار من المؤمنين والمسلمين ...
"Peace be upon you, people of these dwellings, believers and Muslims."
The greeting taught for visiting graves.
Sahih al-Bukhari 1390
Sahih... لعن الله اليهود والنصارى اتخذوا قبور أنبيائهم مساجد ...
"Allah cursed the Jews and the Christians, who took the graves of their prophets as places of worship."
The warning against turning graves into places of worship.
Sahih Muslim 972
Sahih... لا تجلسوا على القبور ولا تصلوا إليها ...
"Do not sit on graves and do not pray facing them."
Sets limits at graves.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Salah, chapter on funerals, discussion of visiting graves. Visiting graves is recommended, with greeting, recitation and dua.
- al-Fatawa al-Hindiyya, Kitab al-Karahiyya, chapter on visiting graves and reciting the Quran at them. The manners of visiting and what is disliked at graves.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.