Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
It is prohibited to change the sex of healthy individuals, as it is a change to the creation of Allah. Since sex change is prohibited, it is invalid, and it has no effect in matters of prayer, inheritance, marriage, custody, alimony, and most rulings.
Answering your question, The Assembly of Muslim Jurists of America, states:
Is sex correction allowed in Islam?
Sex correction for intersex individuals and those with disorders between the genetic and endocrine levels of sex, as well as the internal and external genitalia, is permissible as it is considered a type of legitimate medical treatment, whether that is through surgical treatments or otherwise.
It is obligatory for someone who has deliberately changed their sex, provided that it is possible without any overriding corruption, to apply the rulings of the sex to which they have transitioned.
Is it allowed to change your gender in Islam?
It is prohibited to change the sex of healthy individuals, as it is a change to the creation of Allah. Since sex change is prohibited, it is invalid, and it has no effect in matters of prayer, inheritance, marriage, custody, alimony, and most rulings.
A male who has transitioned to female will receive the share of inheritance designated for males, and is not permitted for this person to marry a man. However, it may be permissible for him to marry a woman who has transitioned to a man, considering their original sex.
An individual who has transitioned from one sex to another is to be treated like an intersex person and those who are not of full sexual capacity in matters of mixing, aligning rows in prayer, and similar issues.
Since surgical operations and treatments related to sex reassignment are prohibited, it is not permissible for a Muslim doctor to perform them or prescribe them. Carrying them out on children would be an even greater offense.
It is permissible for a Muslim doctor to provide medical care to a transgender individual in matters other than transition-related treatments. For example, it is permissible to treat the artificial male genitalia of a female-to-male transgender individual, and the artificial vagina of a male-to-female transgender individual.
Almighty Allah knows best.
Source: AMJA Online
Read also:
Community Rejects Transgender Woman: What to Do?
Changing One’s Gender: Allowed?