Hadithcore
Sahih Muslim, 232a
sahih

Humran, the freed slave of Uthman reported:

One day Uthman b. Affan performed the ablution well, and then said: I saw Allah's Messenger (ﷺ) perform ablution, the best ablution, and then observed: He who performed ablution like this and then went towards the mosque and nothing (but the love of) prayer urged him (to do so), all his previous (minor) sins would be expiated.

حَدَّثَنَا هَارُونُ بْنُ سَعِيدٍ الأَيْلِيُّ، حَدَّثَنَا ابْنُ وَهْبٍ، قَالَ وَأَخْبَرَنِي مَخْرَمَةُ بْنُ بُكَيْرٍ، عَنْ أَبِيهِ، عَنْ حُمْرَانَ، مَوْلَى عُثْمَانَ قَالَ تَوَضَّأَ عُثْمَانُ بْنُ عَفَّانَ يَوْمًا وُضُوءًا حَسَنًا ثُمَّ قَالَ رَأَيْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم تَوَضَّأَ فَأَحْسَنَ الْوُضُوءَ ثُمَّ قَالَ ‏

‏ مَنْ تَوَضَّأَ هَكَذَا ثُمَّ خَرَجَ إِلَى الْمَسْجِدِ لاَ يَنْهَزُهُ إِلاَّ الصَّلاَةُ غُفِرَ لَهُ مَا خَلاَ مِنْ ذَنْبِهِ ‏

‏ ‏.‏

References2 variants
In-Book Reference
Book 2, Hadith 15
USC-MSA web (English) reference
Book 2, Hadith 446 (deprecated numbering scheme)
Sharh · explanationclick to expand
Prayer is the pillar of Islam that has a great reward. As a result, mere walking to perform prayer in a mosque is a reason for forgiving one’s sins and raising his ranks in Paradise. Similarly, Allah makes ablution and prayer reasons for purifying people from the effects of their sins. Also, he promises that performing acts of worship based on their conditions is a reason for forgiveness. In this hadith, the Prophet (ﷺ) said that whoever properly and perfectly performs ablution then walks to perform an obligatory prayer with people, with the congregation, or in the mosque, Allah will forgive his sins. The repeated "or" may be due to a narrator's doubt so the hadith means that a Muslim performs an obligatory prayer with people in a mosque and if they finished it, he would perform it alone in the mosque. Also, it may mean that a Muslim performs an obligatory prayer with people whether in a mosque or somewhere else, so the hadith focusses on performing it with people. As a result, Allah will forgive all of his sins. On the other hand, it was proven in the Quranic and Prophetic texts that it is the minor, not the major sins that will be forgiven, for forgiving major sins necessitates repentance, decisive intention not to commit them again along with some other prerequisites. Finally, the hadith contains the following benefits: (1) Encouragement to properly and perfectly perform ablution, and (2) The virtue of congregational prayer and its great reward..