Allah Most High said concerning Joseph:
“Thus it was, that We might turn evil and immorality away from him. Indeed, he was one of Our chosen servants.”
Through His servant’s sincere devotion to Him, Allah turns away from him the harmful attraction and attachment to outward forms, and keeps him from sexual immorality. Thus, before a person tastes the sweetness of servitude to Allah and sincere devotion to Him, his soul overpowers him, making him follow its desires. But once he tastes sincere devotion and it grows strong in his heart, his desires yield to it without any need for remedial measures.
Allah Most High said:
“Indeed, prayer restrains one from immorality and wrongdoing, and the remembrance of Allah is greater.”
Prayer both wards off what is unwelcome—immorality and wrongdoing—and brings about what is beloved: the remembrance of Allah. Attaining what is beloved is greater than warding off what is unwelcome, for remembering Allah is worshipping Him, and the heart’s worship of Allah is sought for its own sake. By contrast, warding evil off from the heart is sought for a further purpose, as a subsidiary aim. The heart was created to love, desire, and seek the truth.
When the desire for evil arises within it, it seeks to repel that desire, for it corrupts the heart just as weeds growing among crops ruin them. Hence Allah Most High said:
“Successful indeed is the one who purifies it, and failed indeed is the one who corrupts it.”
And Allah Most High said:
“Successful indeed is the one who purifies himself, remembers the name of his Lord, and prays.”
And He said:
“Tell the believing men to lower their gaze and guard their chastity. That is purer for them.”
And Allah Most High said:
“Were it not for Allah’s bounty and mercy upon you, not one of you would ever have become pure.”
Thus He, glorified be He, has declared lowering the gaze and guarding chastity to be more purifying