Wathila b. al-Asqa‘ said God’s messenger led them in prayer over a Muslim and he heard him say, “O God, so and so son of so and so is in Thy protection and in Thy nearer presence, so guard him from the trial in the grave and the punishment in hell. Thou art faithful and true. O God, forgive him and show him mercy. Thou art the forgiving and the merciful One.”
Nafi‘ Abu Ghalib said he prayed along with Anas b. Malik at a man's funeral and he stood opposite his head. Then some people brought along the bier of a woman of Quraish and said, “Abu Hamza (The kunya of Anas b. Malik, the Prophet’s servant), pray over her,” and he stood opposite the middle of the bier. Al-‘Ala’ b. Ziyad said to him, “Thus did I see God’s messenger do. He stood over the bier in the same position as you did in relation to her and in the same position as you did in relation to the man.” He replied, “That is so.”
Tirmidhi and Ibn Majah transmitted it. In Abu Dawud’s version there is something similar, along with an addition containing the words “He stood at the woman’s buttocks.”
He reported that when God’s messenger prayed over a bier he said, “O God, forgive those of us who are living and those of us who are dead, those of us who are present and those of us who are absent, our young and our old, our male and our female. O God, to whomsoever of us Thou givest life keep him faithful to Islam whilst Thou givest him life, and whomsoever of us Thou takest in death take him as a believer. O God, do not withhold from us the reward of faith (the Arabic is variously explained either as translated above, or as the reward of the man who has died, or of the believer. The text is ajrahu which means 'his reward’, or ‘its reward.’ Cf. Mir gat, ii, 365.), or try us after his death.”
Ahmad, Abu Dawud, Tirmidhi and Ibn Majah transmitted it. Nasa'i transmitted it from Abu Ibrahim al-Ashhali who quoted his father’s authority, his version ending at “female”. Abu Dawud’s version has, “Grant him life as a believer and take him in death as a follower of Islam.” It ends, “Do not lead us astray after his death.”