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."
صلى رسول الله ﷺ على جنازة فقال: اللهم اغفر لحينا وميتنا، وصغيرنا وكبيرنا، وذكرنا وأنثانا، وشاهدنا وغائبنا، اللهم من أحييته منا فأحيه على الإيمان، ومن توفيته منا فتوفه على الإسلام، اللهم لا تحرمنا أجره، ولا تضلنا بعده.
Narrated by Abu Dawud (3201), Tirmidhi (1024), and Ibn Majah (1498). Ibn Hibban (3070) and Hakim (1/358) graded it sahih. All of them narrated it through Abu Salama bin Abdul-Rahman, from Abu Hurairah, who mentioned it. Its chain of transmission is sahih.