He—the Exalted—also said:
“Indeed, My servants—you will have no authority over them.” (Al-Hijr 15:42) and the like. Thus the sincere servants of Allah are not led astray by Satan. Al-ghayy (deviation) is the opposite of right guidance and is simply the following of desire. Therefore, whoever feels his soul leaning toward something forbidden should turn to the worship of Allah as He has commanded, devoting his religion purely to Him; that will repel from him every evil and indecency.
(And devoting the religion sincerely to Him entails) (1) fearing Him, loving Him, and worshipping Him alone. When this devotion is complete it keeps sins from occurring; but if it is deficient and sins do appear from the person, it will still wipe them out after the fact. It is like an antidote that wards off the effect of poison and removes it after it has taken hold—
(it therefore both repels sins and eliminates them) (2) just like nourishment from food and drink (which prevents thirst from arising and removes hunger and thirst once they have appeared) (3); or like enjoying the lawful, which keeps the soul from seeking the unlawful, and, should it begin to seek it, restrains and dispels that urge; or like knowledge, which protects the soul from doubt and banishes doubt and misgiving after they have arisen; or like medicine, which preserves health and drives away illness—
(health is maintained by what resembles it, while illness is driven away by its opposite) (4). The same applies to whatever is in the heart.