If a Muslim has a crisis in recognizing his own sex due to the way he feels attracted to members of the same sex, then he may need to consult a doctor rather than a mufti. He should visit a specialist Doctor and ask him about these feelings as there may be a psychiatric or medical reason behind them and if he takes medication he may be treated insha’Allah.
As for the feelings to members of the same sex, in as much he did not indulge in these feelings and did not act upon them, then he can be assured that he will not be held responsible for them.
A Muslim who is struggling with thoughts as such, he should be assured that if he endured that suffering without indulging in sins he will be rewarded by Allah as the Prophet (peace and blessings be upon him) is reported to have said, “No fatigue, nor disease, nor sorrow, nor sadness, nor hurt, nor distress befalls a Muslim, even if it were the prick he receives from a thorn, but that Allah expiates some of his sins for that.” But bearing the suffering does not mean you did not visit a doctor and seek treatment to be assured things are alright.
It is our advice to give out charity, make much istighfar (asking Allah for forgiveness), try to repeat the following du`aas (supplications):
‘Allahumma inni `abduk, ibnu `abdika, ibnu amatika, nasiyati biyadika, madin fiyya hukmuka, `adlun fiyya qada’uka, as’aluka bikulli ismin huwa laka, sammayta bihi nafsaka, aw anzaltahu fi kitabika, aw `al-lamtahu ahadan min khalqika, aw ista’tharta bihi fi `ilmi al-qhaybi `indaka, an taj`ala al-qur’ana al-`azim rabi`a qalbi, wa nura basari, wa jila’a huzani, wa zahaba hammi (O Allah, surely I am your servant and the son of your servant and the son of your bondwoman, my destiny is in Your hand. You are determined in judging me and Just in your decision about me. I beseech of You with every Name of Yours with which You have named Yourself, or revealed in Your book, or taught to anyone of Your creatures, or kept secret exclusively to Yourself, (I beseech You) to make the Qur’an the spring of my heart, the light of my sight, the relief of my grief and the eradication of my catastrophe)’, then Allah will remove his grief and sadness and render it into happiness.”
Allahumma rahmatak arju fala takilni ila nafsi tarfata `aynin, wa aslih li sha’ni kullahu(O Allah! I seek Your mercy; so don’t abandon me to my own devices even for an instant; straighten out all my tangled affairs for me.
Ya hayyu ya qayyumu bi rahmatika astaghithu[O the Ever-Living One, the Self-Subsisting Source of all beings, I invoke Your help].