Ibn al-Qayyim (rahimahullāh) stated:
This is a disease of the heart that differs from every other disease in its nature, its causes, and its remedy. Once it enters the heart it dominates it. Even the doctors (i.e. therapists) are unable to provide a medicine for it. But the medication for this disease lies in knowing firstly that what you have been tested with conflicts with tawhīd.
Thus one should occupy himself with physical and spiritual acts of worship, which in turn would preoccupy him from constantly thinking about that woman. Make lots of du‘ā to Allah (The Most Perfect) that He turns your heart away from her and He returns it back to Him.
However there is no remedy more effective than having ikhlās for Allah, and this is the cure Allah mentioned in His Book wherein He said: “And she certainly determined [to seduce] him, and he would have inclined to her had he not seen the proof of his Lord. And thus [it was] that We should avert from him evil and immorality. Indeed, he was of Our sincere servants.” (Yusuf: 24)
Source: Al-Dā’ wa al-Dawā’, p. 490
Translated by Hisham Abouzeid
3rd of Safar, 1438 (11-02-2016)