The reward of attending
The Prophet ﷺ said: “Whoever attends a funeral until he prays over it will have one qīrāṭ, and whoever attends until the body is buried will have two qīrāṭs.” He was asked what two qīrāṭs are and said: “Like two great mountains” (Sahih al-Bukhari 1325). He also told his Companions to hurry with the funeral (Sahih al-Bukhari 1315).
Before the prayer
You need wudu and to face the Qibla, as for any prayer. The body is placed in front of the imam, and the people stand behind him in rows; an odd number of rows is often preferred. In the Hanafi school the imam stands level with the chest of the deceased, man or woman. If you arrive late, join at the next takbir and make up the missed takbirs after the imam finishes, before the body is lifted.
Step 1: Intention and the first takbir
Intend in your heart to pray the funeral prayer for this deceased, for the sake of Allah, following the imam. Raise your hands and say اللّٰهُ أَكْبَرُ, then fold them as in salah. Quietly recite the opening praise: سُبْحَانَكَ اللّٰهُمَّ وَبِحَمْدِكَ، وَتَبَارَكَ اسْمُكَ، وَتَعَالٰى جَدُّكَ، وَجَلَّ ثَنَاؤُكَ، وَلَا إِلٰهَ غَيْرُكَ. The Hanafis add “wa jalla thanāʾuk” (“and great is Your praise”) in this prayer. The Shafiʿi and Hanbali schools recite Al-Fatiha after the first takbir instead; Ibn ʿAbbas did so and called it Sunnah (Sahih al-Bukhari 1335).
Step 2: The second takbir and salawat
Say اللّٰهُ أَكْبَرُ without raising the hands (Hanafi), and recite the Ibrahimi salawat, the same as in the last sitting of salah: اللّٰهُمَّ صَلِّ عَلٰى مُحَمَّدٍ وَعَلٰى آلِ مُحَمَّدٍ، كَمَا صَلَّيْتَ عَلٰى إِبْرَاهِيمَ وَعَلٰى آلِ إِبْرَاهِيمَ، إِنَّكَ حَمِيدٌ مَجِيدٌ، اللّٰهُمَّ بَارِكْ عَلٰى مُحَمَّدٍ وَعَلٰى آلِ مُحَمَّدٍ، كَمَا بَارَكْتَ عَلٰى إِبْرَاهِيمَ وَعَلٰى آلِ إِبْرَاهِيمَ، إِنَّكَ حَمِيدٌ مَجِيدٌ.
Step 3: The third takbir and the dua for the deceased
Say اللّٰهُ أَكْبَرُ and make dua for the deceased. For an adult, the dua most used in the Hanafi school is: اللّٰهُمَّ اغْفِرْ لِحَيِّنَا وَمَيِّتِنَا، وَشَاهِدِنَا وَغَائِبِنَا، وَصَغِيرِنَا وَكَبِيرِنَا، وَذَكَرِنَا وَأُنْثَانَا، اللّٰهُمَّ مَنْ أَحْيَيْتَهُ مِنَّا فَأَحْيِهِ عَلَى الْإِسْلَامِ، وَمَنْ تَوَفَّيْتَهُ مِنَّا فَتَوَفَّهُ عَلَى الْإِيمَانِ: “O Allah, forgive our living and our dead, those present and those absent, our young and our old, our men and our women. O Allah, whoever of us You keep alive, keep him alive on Islam, and whoever of us You take, take him in faith” (Sunan Abi Dawud 3201; Sunan at-Tirmidhi 1024). Another authentic dua begins اللّٰهُمَّ اغْفِرْ لَهُ وَارْحَمْهُ، وَعَافِهِ وَاعْفُ عَنْهُ (Sahih Muslim 963). The full texts with audio are on janazah dua.
The dua for a child
For a child who died before puberty, there is no need to ask forgiveness for them. Instead ask Allah to make the child a reward for the parents: اللّٰهُمَّ اجْعَلْهُ لَنَا فَرَطًا، وَاجْعَلْهُ لَنَا أَجْرًا وَذُخْرًا، وَاجْعَلْهُ لَنَا شَافِعًا وَمُشَفَّعًا: “O Allah, make him go ahead of us to prepare for us, make him a reward and a treasure for us, and make him an intercessor for us whose intercession is accepted.” For a girl, say اجْعَلْهَا … شَافِعَةً وَمُشَفَّعَةً. See janazah dua for a child.
Step 4: The fourth takbir and the salam
Say اللّٰهُ أَكْبَرُ a fourth time, pause briefly, then turn to the right saying السَّلَامُ عَلَيْكُمْ وَرَحْمَةُ اللّٰهِ, and then to the left. The prayer is complete. In the Hanafi school nothing is recited after the fourth takbir; some scholars of other schools allow a short dua there.
After the prayer
Follow the body to the graveyard if you can, for the second qīrāṭ. When the body is placed in the grave, say: بِسْمِ اللّٰهِ وَعَلٰى سُنَّةِ رَسُولِ اللّٰهِ (Sunan Abi Dawud 3213); see the dua at burial. After burial, the Prophet ﷺ would stand by the grave and say: “Ask forgiveness for your brother and ask that he be made firm, for he is now being questioned” (Sunan Abi Dawud 3221).
Comforting the family
Visit the family, make dua for them and the deceased, and help with food: when Jaʿfar was martyred the Prophet ﷺ said: “Make food for the family of Jaʿfar, for something has come to them that keeps them busy” (Sunan Abi Dawud 3132). A good thing to say is: “To Allah belongs what He took and to Him belongs what He gave; everything with Him has an appointed time, so be patient and hope for reward” (Sahih al-Bukhari 1284). And when you hear of a death, say innā lillāhi wa innā ilayhi rājiʿūn.