Salat al-mayyit is wajib al-kifa’i, i.e. it is obligatory on every Muslim but as soon as it is performed correctly by one of them, it remains no more obligatory on others; but if no one offers the prayer everyone is a sinner.
If the deceased was six years old, the prayer for the deceased is obligatory. In offering this prayer, purity of the body or dress is not necessary; also ghusl, wudhu or tayammum is not obligatory. But the intention of the prayer (niyyah) and facing qibla is essential. The dead body should be placed in such a way that the head of the deceased remains on the right of those who offer the prayer. In the case of the dead body of a male, the Imam should stand near his waist; and in the case of a female, near the chest.
Prayer of deceased has 5 takbirs (including Takbiratul-Ihram).
After the first takbir (i.e., takbiratul-ihram) the Kalima al-shahadatayn is recited. After 2nd the takbir, salawat is recited. After the 3rd takbir, prayer is offered for all the believers and Muslims. After the 4th takbir, prayer is offered especially for the deceased one. Then the 5th takbir is said And the prayer comes to end.
The shortest method of offering this prayer is as follows:
Niyyah: I pray Salat al-mayyit of this corpse Wajib, qurbatan ilal-Laah. Allahu Akbar;
Ashhadu an-la ilaha illallahu wahdahu la sharika lah; Wa Ashhadu Anna Muhammadan
Abduhu wa Rasuluh;
Allahumma salli ‘ala Muhammadin wa Aali Muhammad; Allahu Akbar;
Allahummaghfir li’l Mu’minina wa’l Mu’minaat; Allahu Akbar;
Allahummaghfir li haadha’l mayyit (In case the deceased is a female, say Allahummaghfir li haadhihi’l mayyit);
After the completion of the prayer recite "Rabbana aatina fid-dunya hasanatan wa fi’l aakhera hasanatan waqina adhaban-naar."
It is necessary to mention that even if this prayer is offered by jama’ah, everyone has to recite the whole prayer. It is not correct just to say 'Allahu Akbar' and remain silent between the takbirs. Such a prayer is invalid (batil).