One of the beautiful names of Allah SWT is At-Tawwāb which means the One who forgives those who return to goodness or the One who restores to grace those who repent. In this beautiful Hadith, which gives us a lot of hope, Rasul Allah ﷺ said that a person who repents from sin is like some one who has not sinned. This means that Allah SWT will accept his repentance and not hold him accountable for that act on the day of Judgement. Allahu Akbar!
Allah SWT says in the Quran
إِلَّا مَن تَابَ وَآمَنَ وَعَمِلَ عَمَلًا صَالِحًا فَأُولَٰئِكَ يُبَدِّلُ اللَّهُ سَيِّئَاتِهِمْ حَسَنَاتٍ ۗ وَكَانَ اللَّهُ غَفُورًا رَّحِيمًا
Except for those who repent, believe and do righteous work. For them Allah will replace their evil deeds with good. And ever is Allah Forgiving and Merciful. (25:70)
There is however a few preconditions for our repentance to be accepted. The repentance should be sincere, the person should hate the sin, the person should vow never to return to the sin and makes some changes or takes some corrective action to reduce his chances of returning to that sin.
Abu Sa`id Al-Khudri narrates: The Prophet (ﷺ) said, “Amongst the men of Bani Israel there was a man who had murdered ninety-nine persons. Then he set out asking (whether his repentance could be accepted or not). He came upon a monk and asked him if his repentance could be accepted. The monk replied in the negative and so the man killed him. He kept on asking till a man advised to go to such and such village. (So he left for it) but death overtook him on the way. While dying, he turned his chest towards that village (where he had hoped his repentance would be accepted), and so the angels of mercy and the angels of punishment quarreled amongst themselves regarding him. Allah ordered the village (towards which he was going) to come closer to him, and ordered the village (whence he had come), to go far away, and then He ordered the angels to measure the distances between his body and the two villages. So he was found to be one span closer to the village (he was going to). So he was forgiven.”
Sahih Bukhari Vol. 4, Book 55, Hadith 676
In the hadith above, notice that the man made sincere effort to change and was travelling to a village where righteous people lived in the hope that among them he would not resort to the sins of his past and Allah SWT forgave him even though he had not reached his destination.
We should never lose hope in the infinite mercy of Allah SWT but we should also remember that He is:
Al-Muqsit — The One who is most equitable and just.
Al-Muntaqim — The One who disapproves of wrongdoers.
Al-Hasīb — The One who takes account of all actions and reckons them. The One who is the measurer and accountant of every deed.
Al-Hakam — The One who is the supreme arbitrating magistrate. The One who is the only true judge.
May Allah SWT accept our repentance and make us among the righteous and successful on the Day of Judgement.