It is not permissible for a man to wish to be a woman, nor for a woman to wish to be a man, if what is intended is wishing to change the physical nature with which Allah تعالى created the person. This is because it involves dissatisfaction with Allah’s decree, and it may lead a person to abandon productive efforts and become preoccupied with wishes instead of striving for what benefits him.
Allah تعالى says:
﴿وَلَا تَتَمَنَّوْا مَا فَضَّلَ اللَّهُ بِهِ بَعْضَكُمْ عَلَىٰ بَعْضٍ ۚ لِلرِّجَالِ نَصِيبٌ مِمَّا اكْتَسَبُوا وَلِلنِّسَاءِ نَصِيبٌ مِمَّا اكْتَسَبْنَ ۚ وَاسْأَلُوا اللَّهَ مِنْ فَضْلِهِ إِنَّ اللَّهَ كَانَ بِكُلِّ شَيْءٍ عَلِيمًا﴾
[An-Nisa’: 32]
Ibn Rajab, may Allah have mercy on him, explained that the verse includes wishing for things that are not possible according to Islamic law or divine decree. This includes women wishing to be men and men wishing to be women. The believer should instead compete in religious virtues and strive for them according to his ability.
As-Sa‘di, may Allah have mercy on him, said that Allah تعالى has forbidden people from wishing for what He has favored some people with over others. What is praiseworthy is for a person to strive for what benefits him in matters of religion and worldly life and to ask Allah from His bounty, rather than surrendering to wishes and laziness.
Therefore: A Muslim should not wish to change the sex with which Allah created him, nor should he object to the decree and destiny of Allah. Rather, he should be content with Allah’s creation, strive for what benefits him, and ask Allah from His bounty.
As for a passing feeling that a person does not choose, does not express, and does not accept, then he is not held accountable for it. Accountability applies to what a person deliberately chooses in terms of speech, belief, or action.
And Allah تعالى knows best.