Answered by Sayyidi Habib Umar bin Hafiz (may Allah protect him and benefit us by him)
What can someone do if they experience homosexual inclinations?
Such a person must dislike these inclinations and plead with Allah that He removes them from his heart. He must not act upon these inclinations and he must distance himself from anything which might cause him to act upon them. He will not be taken to account for that which is out of his control but he will be taken to account for being content with these inclinations and acting upon them.
He should repeat this Prophetic dua nineteen times a day:
بِسْمِ اللهِ الرَّحْمَنِ الرَّحِيمِ اللَّهُمَّ يا حَيُّ يَا قَيَّومُ بِرَحْمَتِكَ أسْتَغِيْثُ ومِنْ عَذابِكَ أسْتَجِيرُ أَصْلِحْ لِي شَأنِي كُلَّهُ ولاَ تَكِلْنِي إلى نَفْسِي وَلا إِلى أحَدٍ مِن خَلْقِكَ طَرْفَةَ عَينٍ
Bismillahi’rrahmani’rrahim Allahumma Ya Hayyu ya Qayyum birahmatik astaghithu wa min `adhabika astajir. Aslih li sh’ani kullahu wa la takilni ila nafsa wa la ila ahadin min khalqika tarfata `ayn
In the name of Allah the Compassionate the Merciful. O Allah, O Living! O Sustainer! I call upon Your Mercy for assistance, and from Your chastisement I seek refuge! Make good all my affairs and do not entrust me to myself or any of Your creation for the blink of an eye.