Mishkat al-Masabih 1324
وَعَنْ عَلِيٍّ رَضِيَ اللَّهُ عَنْهُ قَالَ: حَدَّثَنِي أَبُو بَكْرٍ وَصَدَقَ أَبُو بَكْرٍ. قَالَ: سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ يَقُولُ: مَا مِنْ رَجُلٍ يُذْنِبُ ذَنْبًا ثُمَّ يَقُومُ فَيَتَطَهَّرُ ثُمَّ يُصَلِّي ثُمَّ يَسْتَغْفِرُ اللَّهَ إِلَّا غَفَرَ الله لَهُ ثمَّ قَرَأَ هَذِه الاية: (وَالَّذِينَ إِذَا فَعَلُوا فَاحِشَةً أَوْ ظَلَمُوا أَنْفُسَهُمْ ذكرُوا الله فاستغفروا لذنوبهم) رَوَاهُ التِّرْمِذِيُّ وَابْنُ مَاجَهْ إِلَّا أَنَّ ابْنَ مَاجَه لم يذكر الْآيَة
From ʿAli, may Allah be pleased with him, who said: Abu Bakr narrated to me, and Abu Bakr spoke the truth. He said: I heard the Messenger of Allah ﷺ say: "There is no man who commits a sin, then gets up, purifies himself, then prays, then asks Allah for forgiveness, except that Allah forgives him." Then he recited this verse: "And those who, when they commit an immorality or wrong themselves, remember Allah and seek forgiveness for their sins". Reported by at-Tirmidhi and Ibn Majah, except that Ibn Majah did not mention the verse.