وَالَّذِينَ إِذَا فَعَلُواْ فَاحِشَةً أَوْ ظَلَمُواْ أَنْفُسَهُمْ ذَكَرُواْ اللّهَ فَاسْتَغْفَرُواْ لِذُنُوبِهِمْ
And those who, when they have committed Fahishah or wronged themselves with evil, remember Allah and ask forgiveness for their sins.
Therefore, if they commit an error they follow it with repentance and ask forgiveness.
Imam Ahmad recorded that Abu Hurayrah said that the Prophet said,
إِنَّ رَجُلً أَذْنَبَ ذَنْبًا فَقَالَ رَبِّ إِنِّي أَذْنَبْتُ ذَنْبًا فَاغْفِرْهُ
A man once committed an error and said, `O Lord! I committed an error, so forgive me.'
فَقَالَ اللهُ عَزَّ وَجَلَّ عَبْدِي عَمِل ذَنْبًا فَعَلِمَ أَنَّ لَهُ رَبًّا يَغْفِرُ الذَّنْبَ وَيَأْخُذُ بِهِ قَدْ غَفَرْتُ لِعَبْدِي
Allah said, `My servant committed an error and knew that he has a Lord Who forgives or punishes for the error. I have forgiven My servant.'
ثُمَّ عَمِلَ ذَنْبًا اخَرَ فَقَالَ رَبِّ إِنِّي عَمِلْتُ ذَنْبًا فَاغْفِرْهُ
The man committed another error and said, `O Lord! I committed an error, so forgive me.'
فَقَالَ تَبَارَكَ وَتَعَالى عَلِمَ عَبْدِي أَنَّ لَهُ ربًّا يَغْفِرُ الذَّنْبَ وَيَأْخُذُ بِهِ قَدْ غَفَرْتُ لِعَبْدِي
Allah said, `My servant knew that he has a Lord Who forgives or punishes for the sin. I have forgiven My servant.'
ثُمَّ عَمِلَ ذَنْبًا اخَرَ فَقَالَ رَبِّ إِنِّي عَمِلْتُ ذَنْبًا فَاغْفِرْهُ لِي
The man committed another error and said, `O Lord! I committed an error, so forgive me.'
فَقَالَ اللهُ عَزَّ وَجَلَّ عَلِمَ عَبْدِي أَنَّ لَهُ ربًّا يَغْفِرُ الذَّنْبَ وَيَأْخُذُ بِهِ قَدْ غَفَرْتُ لِعَبْدِي
Allah said, `My servant knew that he has a Lord Who forgives or punishes for the error. I have forgiven my servant.'
ثُمَّ عَمِلَ ذَنْبًا اخَرَ فَقَالَ رَبِّ إِنِّي عَمِلْتُ ذَنْبًا فَاغْفِرْهُ لِي
He then committed another error and said, `O Lord! I committed an error, so forgive me.'
فَقَالَ اللهُ عَزَّ وَجَلَّ عَلِمَ عَبْدِي أَنَّ لَهُ ربًّا يَغْفِرُ الذَّنْبَ وَيَأْخُذُ بِهِ أُشْهِدُكُمْ أَنِّي قَدْ غَفَرْتُ لِعَبْدِي فَلْيَعْمَلْ مَا شَاء
Allah said, `My servant knew that he has a Lord Who forgives or punishes for the error. Bear witness that I have forgiven My servant, so let him do whatever he likes.'
A similar narration was collected in the Sahih.
Abdur-Razzaq recorded that Anas bin Malik said,
"I was told that when the Ayah,
وَالَّذِينَ إِذَا فَعَلُواْ فَاحِشَةً أَوْ ظَلَمُواْ أَنْفُسَهُمْ ذَكَرُواْ اللّهَ فَاسْتَغْفَرُواْ لِذُنُوبِهِمْ
(And those who, when they have committed Fahishah or wronged themselves with evil, remember Allah and ask forgiveness for their sins), was revealed, Iblis (Shaytan) cried."
Allah's statement,
وَمَن يَغْفِرُ الذُّنُوبَ إِلاَّ اللّهُ
and none can forgive sins but Allah,
means that none except Allah forgives sins.
Allah said,
وَلَمْ يُصِرُّواْ عَلَى مَا فَعَلُواْ وَهُمْ يَعْلَمُونَ
And do not persist in what (wrong) they have done, while they know.
for they repent from their error, return to Allah before death, do not insist on error, and if they err again, they repent from it.
Allah said here,
وَهُمْ يَعْلَمُونَ
(while they know),
Mujahid and Abdullah bin Ubayd bin Umayr commented,
"Whoever repents, then Allah will forgive him."
Similarly, Allah said,
أَلَمْ يَعْلَمُواْ أَنَّ اللَّهَ هُوَ يَقْبَلُ التَّوْبَةَ عَنْ عِبَادِهِ
Know they not that Allah accepts repentance from His servants. (9;104)
and,
وَمَن يَعْمَلْ سُوءاً أَوْ يَظْلِمْ نَفْسَهُ ثُمَّ يَسْتَغْفِرِ اللَّهَ يَجِدِ اللَّهَ غَفُوراً رَّحِيماً
And whoever does evil or wrongs himself but afterwards seeks Allah's forgiveness, he will find Allah Oft-Forgiving, Most Merciful. (4;110)
and there are several examples similar to this Ayah.
Next, Allah said after this description