Sunan Abi Dawud, Hadith 563

Narrated A person from the Ansar: Sa'id ibn al-Musayyab said: An Ansari was breathing his last. He said: I narrate to you a tradition, and I narrate it with the intention of getting a reward from Allah. I heard the Messenger of Allah say: If any one of you performs ablution and performs it very well, and goes out for prayer, he does not take his right step but Allah records a good work (or blessing) for him, and he does not take his left step but Allah remits one sin from him. Any one of you may reside near the mosque or far from it; if he comes to the mosque and prays in congregation, he will be forgiven (by Allah). If he comes to the mosque while the people had prayed in part, and the prayer remained in part, and he prays in congregation the part he joined, and completed the part he had missed, he will enjoy similarly (i.e. he will be forgiven). If he comes to the mosque when the people had finished prayer, he will enjoy the same.

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

sunnah.com