All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
In fact, if the afflicted person keeps patient and refuses to give in to such urges for sin, he will be rewarded. Ibn Taymiyyah said, “If a person passionately falls in love but keeps chaste and patient and hides his love, he will be rewarded for his piety. The Hadeeth reads: “Whoever falls passionately in love but remains chaste and keeps his love secret then dies, he dies a martyr.” This report has been related on the authority of Yahya Al-Qattaat from Mujaahid from Ibn ‘Abbaas attributing it to the Prophet but its authenticity is questionable and it cannot be used as decisive evidence. However, it is derived from other religious texts that when someone falls in love but abstains from forbidden looks, acts, and words, keeps his love a secret, does not express it verbally so as not to make prohibited speech either in the form of complaints to people, expression of a sinful desire, or requesting the loved one to feel the same about him, and has patience upon obeying Allaah, abstaining from disobeying Him, and enduring the pain of love in his heart like an injured person endures the pain of injury, this would be a cause for him being among those who fear Allaah and have patience. Allaah, The Exalted, says (what means): {Indeed, he who fears Allaah and is patient, then indeed, Allaah does not allow to be lost the reward of those who do good."} [Quran 12:90].” [End of quote]
Some devoted worshippers even suggested that a person who is afflicted with a sinful urge but strives in repelling it, and hopes for the reward of Allaah is superior to the one whose heart is free of such urges as Ibn Al-Qayyim cited in his book Tareeq Al-Hijratayn.
Therefore, we advise that brother to have patience and perform righteous deeds, and to implore Allaah to purify his heart from such urges for sin. He must ignore Satan’s attempts to dishearten him and drive him to despair of the mercy of Allaah.
As for Ibn Al-Qayyim’s statement cited in the question, it refers to the person who gives in to the urge of loving beardless boys and is determined to pursue it and resolves to act upon that urge. This is the dispraised person who deserves punishment.
For more benefit, please refer to Fataawa 18605 and 225781.
Allaah Knows best.