The Messenger of Allah ﷺ said, "Whoever follows a funeral procession until the prayer is offered for the deceased will have a reward of one qirat, and whoever walks with the funeral until the burial is completed will have a reward of two qirats. And a qirat is like the mountain of Uhud."
أخبرنا قتيبة قال حدثنا عبثر عن برد أخي يزيد بن أبي زياد عن المسيب بن رافع قال سمعت
قال رسول الله ﷺ من تبع جنازة حتى يصلى عليها كان له من الأجر قيراط ومن مشى مع الجنازة حتى تدفن كان له من الأجر قيراطان والقيراط مثل أحد