Sunan an-Nasa'i, Volume 6, Book 47, Hadith 5035 (DarusSalam)

It was narrated from Abu Hurairah that: The Prophet [SAW] said: "Whoever follows the funeral procession of a Muslim out of faith and in the hope of reward, then offers the funeral prayer for him and waits until he is placed in his grave, then he will have two Qirats, each of which is like Mount Uhud. Whoever offers the funeral prayer for him then returns, he will have one Qirat."

أَخْبَرَنَا عَبْدُ الرَّحْمَنِ بْنُ مُحَمَّدِ بْنِ سَلَّامٍ قَالَ حَدَّثَنَا إِسْحَقُ يَعْنِي ابْنَ يُوسُفَ بْنِ الْأَزْرَقِ عَنْ عَوْفٍ عَنْ مُحَمَّدِ بْنِ سِيرِينَ عَنْ أَبِي هُرَيْرَةَ عَنْ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ مَنْ اتَّبَعَ جَنَازَةَ مُسْلِمٍ إِيمَانًا وَاحْتِسَابًا فَصَلَّى عَلَيْهِ ثُمَّ انْتَظَرَ حَتَّى يُوضَعَ فِي قَبْرِهِ كَانَ لَهُ قِيرَاطَانِ أَحَدُهُمَا مِثْلُ أُحُدٍ وَمَنْ صَلَّى عَلَيْهِ ثُمَّ رَجَعَ كَانَ لَهُ قِيرَاطٌ

sunnah.com