This is specific to Khomeiniās interpretation and one or two other people as far as Iām aware. In Iran, transexual surgeries are only performed male-to-female, because the reasoning is that itās easier to integrate a transexual woman into Islamic society in a halaal way than it is to integrate a male with SSA. Which is a completely bizarre interpretation of Islamic law, but thatās Iran for you. The way itās practiced is totally inhumane since the law forces people to have the surgeries sometimes against their will and this can often also apply to homosexual men if theyāre considered to be effeminate enough. Itās totally bonkers to most of the Muslims in the world, but so are a lot of things Khomeini has done.
Sunni and traditional Shia have been developing a theology of intersex people and transgender for some time, since many Central Asian and Middle Easter cultures historically have recognized third sexes of various kinds. The common thread is that people who are genuinely physically intersex are not at fault in anyway because this is a malady beyond their control. So, fatwas in modern times now that gender reassignment surgery is available, have tended to rule that intersex people should be examined by qualified physicians who can determine whether their medical nature is male or female and determine a solution accordingly. Or, they can choose not to undergo any alteration and simply live in a manner that doesnāt leave them vulnerable to zina or compromise modesty (so, like, an ambiguously intersex person with male only attraction might choose to identify as female, spend time in womenās areas, and wear hijab to protect themselves from zina). For people who are not intersex, the issue is less clear. A hadith in Sunan Abu Dawud states that the Prophet (peace be upon him) would not permit a transwoman who persisted in dressing as a female to be killed, but instead sent the person away. So, basically, itās wrong to harm a person who is transgender because they have gender dysphoria, but itās also not acceptable to allow them to continue pretending to be other than what they are in a moral society especially for the immoral purpose of committing acts of zina. Itās a form of lying.
Itās a complex issue and as more science is revealed on transgenderism, I expect weāll see corresponding changes in how transgenderism is dealt with in Muslim society. My personal reasoning is that itās a violation of basic moral decency to perform life-altering surgery on a healthy person and that it amounts to mutilation. Especially regarding the Iranian solution, it strikes me as being in the same ethical category as the lobotomy. Iām not a doctor or a mental health professional, though, so I could be off base about that. Intersex people have a hard row to hoe and so I support them having surgical options if they want them, but I think itās best to wait until the person is an adult and can make that decision for themself instead of having it made for them in infancy. Whatever the situation, people with gender dysphorias should be treated with compassion and respect.