From the Seattle Times:
In the Islamic Republic of Iran, gay male sex still carries the death penalty and lesbians are lashed, but hundreds of people are having their gender changed legally, bolstered by the blessings of members of the ruling Shiite clergy.
“Approval of gender changes doesn’t mean approval of homosexuality. We’re against homosexuality,” says Mohammed Mahdi Kariminia, a cleric in the holy city of Qom and one of Iran’s foremost proponents of using hormones and surgery to change sex. “But we have said that if homosexuals want to change their gender, this way is open to them.”
…
No Muslim society has tackled the question with the open-mindedness of Shiite Iran. That’s probably because the father of the revolution himself, Ayatollah Ruhollah Khomeini, penned the groundbreaking “fatwas” that approved gender reassignment four decades ago.
Khomeini reasoned that if men or women wished so intensely to change their sex, to the point that they believed they were trapped inside the wrong body, then they should be permitted to transform that body and relieve their misery. His opinion had more to do with what isn’t in the Quran than what is. Sex change isn’t mentioned, Khomeini’s thinking went, and so there are no grounds to consider it banned.
More here.