The prescribed practice for us when visiting the graves of the prophets, the righteous, and all other believers is of the same kind as what is prescribed when attending their funerals. Just as the purpose of the funeral prayer is to supplicate for the deceased, so the purpose of visiting his grave is likewise to supplicate for him, as is established from the Prophet ﷺ in the authentic collections, the Sunan, and the Musnad. He used to teach his Companions that when they visited the graves one of them should say:
“Peace be upon you, inhabitants of these dwellings—people of faith. If Allah wills, we too shall soon join you. May Allah have mercy on those of us who have gone before and those who come later. We ask Allah to grant us and you well-being. O Allah, do not deprive us of their reward, do not try us after them, and forgive us and them.”
This is a specific supplication for the deceased, just as the funeral prayer contains both general and specific invocations:
“O Allah, forgive our living and our dead, those present and those absent, our young and our old, our males and our females. Truly, You know our comings and goings…"
(1) The word qubur (graves) is absent in MS A.
(2) The passage between the two numerals is missing in MS D.
(3) The passage between the two numerals is missing in MS D.
(4) The phrase wa-l-Musnad (and in the Musnad) is absent in MS T.
(5) The word minna (from us) is absent in MS T.
(6) Sources for this supplication: Sahih Muslim, Book of Funerals, chapter “What is to be said upon entering the graves,” hadith nos. 974–975; Sunan al-Tirmidhi, Book of Funerals, chapter “What a man should say when he enters the cemetery,” hadith no. 1053 (3/369); Sunan Abi Dawud, Book of Funerals, chapter “What is to be said when visiting or passing by graves,” hadith no. 3237 (3/558–559); Sunan Ibn Majah, Book of Zuhd, chapter “Mention of the Basin,” hadith no. 4306 (2/1439); Musnad Ahmad 2:300, 375, 408; 6:71, 76, 111, 180, 221; Sunan al-Nasaʾi 4:93–94.
(7) MS T adds at the beginning of the supplication: “Allahumma, do not deprive us of their reward and do not test us after them…” and the rest of the prayer—an interpolation by the scribe.
(8) The phrase innaka taʿlamu mutaqallabana wa mathwana (indeed, You know our comings and goings and our final abode) is missing in MSS At.