Frequent repenting from sins and then returning to the same sin

Question
What do you advise a person who commits sin and then repents, then commits sin and then repents, and so on? How can he give up the sin altogether?
Answer

There is no doubt that a person who disobeys Allaah, Most Exalted, should repent for his sins. Repentance is obligatory and it should be done immediately.

(وَتُوبُوٓاْ إِلَى ٱللَّهِ جَمِيعًا)
… and turn to Allaah in repentance, all of you.” (AN-Noor 31)

If his self, his desires and his devil have overwhelmed him, and thus he commits the sin again, he should repent again. However, he must fight the devil, his desires and himself and be determined not to sin again, otherwise he would be the subject of Allaah’s Anger. He should not sin again belittling the Right of Allaah, because the one who repeats sinning is in a manner belittling Allaah. A person should stay firm upon repentance upon the following conditions:
1.    Stop sinning immediately,
2.    be determined not to repeat this, and
3.    be regretful.
If these conditions are found, then his repentance is accepted by Allaah. If he repeats it, he should repent again, and so on. However, a person should know the One whom he is disobeying and the magnitude of the Punishment from Allaah. If he knows this, he will not repeat the sin again, even though he will feel weakness in faith from time to time. There are causes for sin and there are things which will prevent it. A person must exert his effort to find those means to stop him from committing sin, and he must do away with those things which give him access to sins. A person should seek Refuge in Allaah through supplication and have trust in His Refuge. He should increase in good deeds, because good deeds call out, like the pious predecessors said, ‘My sister! My sister!’ which would beckon another good deed. The person must refrain from sins and evil actions, because bad deeds also call out, ‘My sister! My sister!’ A person must avoid bad friends who adorn sins for him. He should be steadfast with those who call upon their Lord, night and day, from among the righteous people. If this happens, he will be without doubt away from sins. This is not to say that he will be protected against sinning, but the point is whenever he avoids bad people and joins the company of good people, it is most likely he will do good deeds.