In a certain case, one may commit a sin, repent from it, and then commit it again even though he repented from it.
So what should one do if they are in this situation? This fatwā from Sheikh Muḥammad ibn Ṣāliḥ al-‘Uthaymīn (رحمه الله) will answer this, ʾIn shāʾ Allāh.
ibn al-‘Uthaymīn (رحمه الله) was asked:
"A person repents from a sin, but then returns to that sin over and over again, only to repent each time. However, after having repented the last time, he managed not to return in that sin. What is the ruling regarding this person's repentance?"
Then ibn al-‘Uthaymīn (رحمه الله) answered:
"The sinner's repentance is correct; in fact, each time he repented it was correct. Every time he sinned and then repented, Allāh Almighty accepted his repentance. A person who sins should repent after sinning, whether he is committing that sin for the first, second, or third time; Allāh Almighty says:
'Say: O My servants who have transgressed against themselves? Despair not of the Mercy of Allāh, verily Allāh forgives all sins. Truly, He is Oft-Forgiving, Most Merciful.' (1)
What is important, though, is that his repentance should be sincere, and that he should resolve not to return to the sin. One is not truly repenting when one intends all the while to return to the sin he repented from, such repentance is incorrect. The point is that every time a person repents sincerely, Allāh Almighty accepts that person's repentance." (2)
Summarizing this, one should repent sincerely from that sin and keep repenting until he is completely astray from that sin.
I ask Allāh to have great mercy upon Sheikh Muḥammad ibn Ṣāliḥ al-‘Uthaymīn, and reward him for his great contributions to the religion of Islām.
May Allāh bless you, and shukran.
1. Qurʾān 39:53
2. Fatāwā Islāmīyah vol no. 7, page no. 271/272