they went out to the graveyards, one of them should say:
“Peace be upon the inhabitants of these dwellings.”
In another wording:
“Peace be upon you, O inhabitants of the dwellings—believers and Muslims alike. If Allah wills, we shall surely join you. We ask Allah for well-being for us and for you.” (Related by Muslim.)
Muslim also transmits from Abū Hurayrah that “the Messenger of Allah, peace and blessings be upon him, went out to the cemetery and said: ‘Peace be upon you, abode of a believing people; and, if Allah wills, we shall soon join you.’”
He likewise narrates from ʿĀʾishah—within a longer report—that the Prophet, peace be upon him, said: “Gabriel came to me and said, ‘Your Lord commands you to go to the people of al-Baqīʿ and seek forgiveness for them.’” She said, “I asked, ‘O Messenger of Allah, what should I say?’” He replied, “Say: ‘Peace be upon the inhabitants of these dwellings, believers and Muslims. May Allah have mercy on those of us who have gone ahead and on those who come later; and, if Allah wills, we shall surely join you.’”
Ibn Mājah records from ʿĀʾishah that she said: “I missed him and found him in al-Baqīʿ. He was saying: ‘Peace be upon you, abode of a believing people. You have gone on ahead of us, and we shall follow you. O Allah, do not deprive us of their reward, and do not try us after them.’”
Ibn ʿAbbās, may Allah be pleased with them both, said: “The Messenger of Allah, peace and blessings be upon him, passed by the graves of Madinah, turned toward them, and said: ‘Peace be upon you, O inhabitants of the graves. May Allah forgive us and you…’”