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?
They must dislike these inclinations and plead with Allah that He removes them from their hearts. They must not act upon these inclinations and they must distance themselves from anything which might cause them to act upon them. They will not be taken to account for that which is out of their control but they will be taken to account for being content with these inclinations and acting upon them.
They 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.