When you hear the sad news of a believer who has passed away, recite as recommended in this verse

ٱلَّذِينَ إِذَآ أَصَٰبَتْهُم مُّصِيبَةٌ قَالُوٓا۟ إِنَّا لِلَّهِ وَإِنَّآ إِلَيْهِ رَٰجِعُونَ
Who, when a misfortune befalls them, say: Surely we are Allah's and to Him we shall surely return.

It's mustahab (recommended) that on the first night after the burial of the deceased, between Maghrib and Isha one should recite two rakats prayer. This is known as Namaz-e-Wahshat because for the dead person the most horrifying and difficult is the first night.

عن النبي صلى الله عليه وسلم ، قال : ( لا يأتي على الميت أشد من الليلة الأولى ، فارحموا موتاكم بالصدقة ، فمن لم يجد فليصل ركعتين

If unable to recite on the first night, then may be recited on the second or even third night after burial. However, the recommendation is to perform charity first, and also its only recommended that the wali of the deceased recites the prayer (and not everyone), since the hadith quoted above explicitly says 'one of you may recite'

The prayer is conducted like any other 2 Rakat prayer (Morning prayer), as follows:

  1. Perform Niyyat, and recite Takbirat-ul-Ehram
  2. Recite Surah al-Fatiha

    بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
    In the name of Allah, the Beneficent, the Merciful.
    ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ
    All praise is due to Allah, the Lord of the Worlds.
    ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
    The Beneficent, the Merciful.
    مَٰلِكِ يَوْمِ ٱلدِّينِ
    Master of the Day of Judgment.
    إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ
    Thee do we serve and Thee do we beseech for help.
    ٱهْدِنَا ٱلصِّرَٰطَ ٱلْمُسْتَقِيمَ
    Keep us on the right path.
    صِرَٰطَ ٱلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ ٱلْمَغْضُوبِ عَلَيْهِمْ وَلَا ٱلضَّآلِّينَ
    The path of those upon whom Thou hast bestowed favors. Not (the path) of those upon whom Thy wrath is brought down, nor of those who go astray.

  3. After Al Fatiha, recite Ayat al Kursi

    ٱللَّهُ لَآ إِلَٰهَ إِلَّا هُوَ ٱلْحَىُّ ٱلْقَيُّومُ لَا تَأْخُذُهُۥ سِنَةٌ وَلَا نَوْمٌ لَّهُۥ مَا فِى ٱلسَّمَٰوَٰتِ وَمَا فِى ٱلْأَرْضِ مَن ذَا ٱلَّذِى يَشْفَعُ عِندَهُۥٓ إِلَّا بِإِذْنِهِۦ يَعْلَمُ مَا بَيْنَ أَيْدِيهِمْ وَمَا خَلْفَهُمْ وَلَا يُحِيطُونَ بِشَىْءٍ مِّنْ عِلْمِهِۦٓ إِلَّا بِمَا شَآءَ وَسِعَ كُرْسِيُّهُ ٱلسَّمَٰوَٰتِ وَٱلْأَرْضَ وَلَا يَـُٔودُهُۥ حِفْظُهُمَا وَهُوَ ٱلْعَلِىُّ ٱلْعَظِيمُ
    Allah is He besides Whom there is no god, the Everliving, the Self-subsisting by Whom all subsist; slumber does not overtake Him nor sleep; whatever is in the heavens and whatever is in the earth is His; who is he that can intercede with Him but by His permission? He knows what is before them and what is behind them, and they cannot comprehend anything out of His knowledge except what He pleases, His knowledge extends over the heavens and the earth, and the preservation of them both tires Him not, and He is the Most High, the Great.

  4. Perform Ruku and Sajdah as any other prayer
  5. Recite Surah al-Fatiha for the second unit
  6. After Al Fatiha, recite Surah Qadr 10 Times

    بِّسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ إِنَّآ أَنزَلْنَٰهُ فِى لَيْلَةِ ٱلْقَدْرِ
    Surely We revealed it on the grand night.
    وَمَآ أَدْرَىٰكَ مَا لَيْلَةُ ٱلْقَدْرِ
    And what will make you comprehend what the grand night
    لَيْلَةُ ٱلْقَدْرِ خَيْرٌ مِّنْ أَلْفِ شَهْرٍ
    The grand night is better than a thousand months.
    تَنَزَّلُ ٱلْمَلَٰٓئِكَةُ وَٱلرُّوحُ فِيهَا بِإِذْنِ رَبِّهِم مِّن كُلِّ أَمْرٍ
    The angels and Jibreel descend in it by the permission of their Lord for every affair,
    سَلَٰمٌ هِىَ حَتَّىٰ مَطْلَعِ ٱلْفَجْرِ
    Peace! it is till the break of the morning.

  7. Perform Qunoot, ruku and sajdah as usual
  8. Conclude the prayer with Tashahud and Salaam
  9. Then recite a salwat mentioning the name of the deceased

    اللهم صل ع لی محمد و آل محمد و ابعث ثوابها الی قبر ذلك المیت فلان بن فلان

    O' Allah! Bless Muhammad and his progeny, and assign the reward to the grave of (mention the name of the deceased).