The Messenger of Allah ﷺ prayed over a funeral and said, "Allah, forgive our living and our dead, our young and our old, our males and our females, those of us present and those absent. Allah, whoever among us You keep alive, let him live in faith, and whoever among us You take in death, let him die in Islam. Allah, do not deprive us of his reward, and do not lead us astray after him."
صلى رسول الله ﷺ على جنازة فقال: اللهم اغفر لحينا وميتنا، وصغيرنا وكبيرنا، وذكرنا وأنثانا، وشاهدنا وغائبنا، اللهم من أحييته منا فأحيه على الإيمان، ومن توفيته منا فتوفه على الإسلام، اللهم لا تحرمنا أجره، ولا تضلنا بعده.
It was narrated by Abu Dawud (3201), Tirmidhi (1024), and Ibn Majah (1498) through multiple routes from Yahya bin Abu Kathir, from Abu Salama bin Abdul-Rahman, from Abu Hurairah, who related it, except that Ibn Majah narrated it through another route from Abu Salama with a similar chain. Yahya bin Abu Kathir is a mudallis, but he was corroborated in Ibn Majah's version, where it was narrated through Muhammad bin Ibrahim, from Abu Salama, from Abu Hurairah. He also explicitly stated "I heard" (haddathani) in the version of Hakim (1/358), who graded it sahih according to the criteria of the two Shaykhs (Bukhari and Muslim), and Ibn Hibban (3070) also graded it sahih.Yahya bin Abu Kathir has other routes as well, including what Uzai narrated from him, from Abu Ibrahim Ashhali, from his father, who said, "Whenever the Messenger of Allah ﷺ performed the funeral prayer, he would say, 'O Allah, forgive our living and our dead, those present among us and those absent, our young and our old, our males and our females.'" This was narrated by Tirmidhi (1024) and Nasai (1986). Tirmidhi said, "The hadith of the father of Abu Ibrahim is hasan sahih," and he also said, "I heard Muhammad, meaning Bukhari, say, 'The most sahih of the narrations on this matter is the hadith of Yahya bin Abu Kathir, from Abu Ibrahim Ashhali, from his father.' I asked him about the name of Abu Ibrahim, and he did not know it." End of quote. Abu Hatim said regarding Abu Ibrahim Ashhali, "It is not known who he is," as found in Jarh wa Tadil (9/332). Hafiz classified him at the level of "acceptable," meaning when corroborated, and he has indeed been corroborated.Among these routes is also what Hisham Dastawai and Ali bin Mubarak narrated of this hadith from Yahya bin Abu Kathir, from Abu Salama bin Abdul-Rahman, from the Prophet ﷺ, as a mursal narration. Hakim (1/358) narrated it through the route of Umar bin Yunus bin Qasim Yamami, who said, "Ikrima bin Ammar narrated to us, from Yahya bin Abu Kathir, who said, 'Abu Salama bin Abdul-Rahman narrated to me,' who said, 'I asked Ayesha, Mother of the Believers, how the Messenger of Allah ﷺ performed the prayer over the dead,' and she said, 'He used to say, "O Allah, forgive our living and our dead, our males and our females, those present among us and those absent, our young and our old. O Allah, whichever of us You keep alive, keep him alive upon Islam, and whichever of us You take, take him upon faith."'"Hakim presented this as a sahih supporting witness according to the criteria of Muslim for the hadith of Abu Hurairah. However, Tirmidhi said, "The hadith of Ikrima bin Ammar is not preserved, and Ikrima sometimes errs in the hadith of Yahya." I say, it is as he said, and the majority hold that his narration is inconsistent (mudtarib), especially in his narration from Yahya bin Abu Kathir, because he did not have a written record from him, and this may be one instance of that, since it is well known that this hadith was narrated by Uzai, from Yahya bin Abu Kathir, who said, "Abu Salama narrated to me, from Abu Hurairah."Yahya bin Abu Kathir has other routes as well, including what he narrated from Abdullah bin Abu Qatada, from his father, that he witnessed the Prophet ﷺ praying over a deceased person, and heard him say, "O Allah, forgive our living and our dead, those present among us and those absent, our young and our old, our males and our females." He said, "And Abu Salama narrated to me these same eight phrases, adding two more phrases, 'Whichever of us You keep alive, keep him alive upon Islam, and whichever of us You take, take him upon faith.'"This was narrated by Imam Ahmad (17546, 22554) through two routes from Hammam, who said, "Yahya bin Abu Kathir narrated to us, saying, 'Abdullah bin Abu Qatada narrated to us, from his father,'" and he related it as above. Ibn Abu Kathir explicitly stated "I heard" (haddathani) in one of his two versions. This route was mentioned by Dhahabi in Mukhtasar Sunan al-Kubra (3/1385), and he passed over it in silence.