Muwatta Malik, Book 16, Hadith 17 (USC-MSA)

Yahya related to me from Malik from Said ibn Abi Said al-Maqburi from his father that he had asked Abu Hurayra, "How do you pray over the dead?" and Abu Hurayra replied, "By the Life of Allah, I will tell you! I follow with the family and when the corpse is put down I say 'Allah is greater' and praise Allah and ask for blessings on His Prophet. Then I say, 'O Allah, he is Your slave and the son of Your male slave and Your female slave. He used to testify that there is no god but You and that Muhammad is Your slave and Your Messenger, and You know that best. O Allah, if he acted well, then increase for him his good action, and if he acted wrongly, then overlook his wrong actions. O Allah, do not deprive us of his reward, and do not try us after him.'" Allahumma inna huwa abduka wa'bnu abdika wa'bnu amatika. Kana yash-hadu an la ilaha illa ant wa anna Muhammadan abduka wa rasooluka, wa anta alamu bihi. Allahumma in kana muhsinan zid fi ihsanihi, wa in kana musiyan fa tajawaz an sayatihi. Allahumma la tahrimna ajrahu wa lataftina badahu.

حَدَّثَنِي يَحْيَى، عَنْ مَالِكٍ، عَنْ سَعِيدِ بْنِ أَبِي سَعِيدٍ الْمَقْبُرِيِّ، عَنْ أَبِيهِ، أَنَّهُ سَأَلَ أَبَا هُرَيْرَةَ كَيْفَ تُصَلِّي عَلَى الْجَنَازَةِ فَقَالَ أَبُو هُرَيْرَةَ أَنَا لَعَمْرُ اللَّهِ، أُخْبِرُكَ أَتَّبِعُهَا، مِنْ أَهْلِهَا فَإِذَا وُضِعَتْ كَبَّرْتُ وَحَمِدْتُ اللَّهَ وَصَلَّيْتُ عَلَى نَبِيِّهِ ثُمَّ أَقُولُ اللَّهُمَّ إِنَّهُ عَبْدُكَ وَابْنُ عَبْدِكَ وَابْنُ أَمَتِكَ كَانَ يَشْهَدُ أَنْ لاَ إِلَهَ إِلاَّ أَنْتَ وَأَنَّ مُحَمَّدًا عَبْدُكَ وَرَسُولُكَ وَأَنْتَ أَعْلَمُ بِهِ اللَّهُمَّ إِنْ كَانَ مُحْسِنًا فَزِدْ فِي إِحْسَانِهِ وَإِنْ كَانَ مُسِيئًا فَتَجَاوَزْ عَنْ سَيِّئَاتِهِ اللَّهُمَّ لاَ تَحْرِمْنَا أَجْرَهُ وَلاَ تَفْتِنَّا بَعْدَهُ ‏.‏

sunnah.com

also referenced under: Book 16, Hadith 539 (In-Book)