The Prophet ﷺ said, "Whoever follows the funeral procession of a Muslim out of faith and hoping for reward, then prays over the deceased and waits until the body is placed in the grave, will receive two qirats of reward, each one like the mountain of Uhud. And whoever prays over the deceased and then returns will receive one qirat."
أخبرنا عبد الرحمن بن محمد بن سلام قال حدثنا إسحق يعني ابن يوسف بن الأزرق عن عوف عن محمد بن سيرين
عن النبي ﷺ قال من اتبع جنازة مسلم إيمانا واحتسابا فصلى عليه ثم انتظر حتى يوضع في قبره كان له قيراطان أحدهما مثل أحد ومن صلى عليه ثم رجع كان له قيراط