Sunan Ibn Majah, Book 6, Hadith 1565 (In-Book) ⓘ
It was narrated that Abu Hurairah said: “When the Messenger of Allah offered the funeral prayer he would say: ‘Allahummaghfir lihayyina wa mayyitina, wa shahidina wa gha’ibina, wa saghirina wa kabirina, wa dhakarina wa unthana. Allahumma man ahyaitahu minna faahyihi ‘alal-Islam, wa man tawaffaytahu minna fa tawaffahu ‘alal- iman. Allahumma la tahrimna ajrahu wa la tudillana ba’dah. [O Allah, forgive our living and our dead, those who are present and those who are absent, our young and our old, our males and our females. O Allah, whomever of us You cause to live, let him live in Islam, and whomever of us You cause to die, let him die in (a state of) faith. O Allah, do not deprive us of his reward, and do not let us go astray after him].’”
حَدَّثَنَا سُوَيْدُ بْنُ سَعِيدٍ، حَدَّثَنَا عَلِيُّ بْنُ مُسْهِرٍ، عَنْ مُحَمَّدِ بْنِ إِسْحَاقَ، عَنْ مُحَمَّدِ بْنِ إِبْرَاهِيمَ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، قَالَ كَانَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ إِذَا صَلَّى عَلَى جِنَازَةٍ يَقُولُ " اللَّهُمَّ اغْفِرْ لِحَيِّنَا وَمَيِّتِنَا وَشَاهِدِنَا وَغَائِبِنَا وَصَغِيرِنَا وَكَبِيرِنَا وَذَكَرِنَا وَأُنْثَانَا اللَّهُمَّ مَنْ أَحْيَيْتَهُ مِنَّا فَأَحْيِهِ عَلَى الإِسْلاَمِ وَمَنْ تَوَفَّيْتَهُ مِنَّا فَتَوَفَّهُ عَلَى الإِيمَانِ اللَّهُمَّ لاَ تَحْرِمْنَا أَجْرَهُ وَلاَ تُضِلَّنَا بَعْدَهُ " .
also referenced under: Hadith 1498 (Reference) & Volume 2, Book 6, Hadith 1498 (DarusSalam)