Praise be to Allah, and may peace and blessings be upon the Messenger of Allah. To proceed:
If the person was biologically male from the outset, with complete male organs and characteristics, and was not intersex, and then underwent surgery merely because he felt or desired to be a woman, then this operation does not change his biological sex. Rather, it changes some aspects of his appearance and bodily organs. Therefore, according to Islamic rulings, he remains a man.
Scholars have prohibited sex-reassignment surgery in this situation because it constitutes changing the creation of Allah, the Most High, and because it involves imitating the opposite sex. Allah, the Most High, said concerning Satan:
﴿And I will command them, and they will change the creation of Allah.﴾ [An-Nisa': 119].
The Prophet ﷺ also prohibited men from imitating women and women from imitating men. It is also authentically reported that he ﷺ prohibited men who imitate women from entering upon women when such men describe women's physical beauty and are attentive to it.
Accordingly, it is not permissible for women to be alone in seclusion with him, nor to treat him as a woman, nor for a woman to uncover before him what she would normally uncover before other women; because in reality he remains a man, even if his outward appearance has become similar to that of women.
As for hosting him and helping him remain firm in Islam, he should not be abandoned or treated harshly in a manner that could cause him to turn away from the religion. Rather, efforts should be made to strengthen him, teach him the rulings of Islam, and help him repent and reform himself, while observing the Islamic guidelines, such as conducting meetings in the presence of more than one person and avoiding seclusion with women.
He should also be referred to a trustworthy mental-health professional if he is experiencing a psychological disorder, and reliable scholars should be consulted to guide him and teach him the religious rulings he needs to know.
Guidance and success are in the hands of Allah, the Most High. He said:
﴿Indeed, you cannot guide whom you love, but Allah guides whom He wills.﴾ [Al-Qasas: 56].
And Allah, the Most High, knows best.