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 Koran than what is. Sex change isn't mentioned, Khomeini's thinking went, so there are no grounds to consider it banned.
"There is no reason why not," says Kariminia, the cleric. "Each human being is the owner of his body, and therefore he can make changes."
Before Khomeini, some Islamic edicts had approved sex changes for hermaphrodites, but nobody had given carte blanche for sex reassignment without medical deformities. To this day, some Shiite clerics argue against operating on healthy bodies.
But in a low stone house in the twisting alleys of Qom, Kariminia is writing his doctoral thesis on transgender law. His writings tease out the work of Khomeini, tackling legal questions such as: If a married woman wishes to become a man, must she first get permission from her husband? Must a man seek permission from his wife?
"Islam has recognized the rights of transgender. We can't say to anybody that they must be a man or a woman," Kariminia says. "But do you think just because they don't have legal or Islamic problems, their problems are solved? I certainly do not."
Iran's acceptance of sex-reassignment operations raises the specter that gays and lesbians may be able to find a place for themselves here only by changing their gender. Some transgender patients complain that lesbians and gays are exploiting the surgery to create a legal way to sleep with their preferred partners.
Mir-Djalali, a kinetic man with an irrepressible enthusiasm for spelling out the more delicate details of the surgeries, says that in 15 years he's transformed about 320 men into women, and 70 women into men.
He is careful to point out that those were only half of the would-be patients who came to his office. He disqualified the others after they were examined by a panel of three psychiatrists.
The psychiatric team tries to sort out homosexuality from gender disorder by asking a series of questions. A man hoping to become a woman, for example, is asked whether he has dreamed of removing his penis. Gay men recoil at the idea, the doctor says -- but transgender men are eager at the suggestion.
"They say, 'Yes, yes, yes, I've always dreamed of it,' " Mir-Djalali says.
But the screening is the only restriction in Iran's relatively lax system. In most countries where sex-change operations are performed, doctors urge their patients to live for some time in the guise of their preferred gender before taking any drastic measures.
But in Iran, there's no waiting period. After passing the psychological screening, the patients are hustled into treatment. After all, in the interim they are considered gay, and therefore outlaws.
"By the time they come to me, they've made up their minds," Mir-Djalali says. "They've already worn makeup and women's dresses. They don't need to try."
The 25 years since the revolution have been an era of turmoil and liberation for Iran's transgender community. Despite the tolerance contained in Khomeini's fatwas, many suffered bitterly when he came to power, caught in revolutionary purges meant to turn Iran into a pure Islamic republic.
"Twenty years ago, we were living in secret and with fear," says Maryam Khatoon Molkara, 54, one of the elder stateswomen of the transgender movement. "I wanted to become a woman and also do something for the others."
Today Molkara lives in a second-floor walk-up in a dingy part of Tehran, where she receives her visitors in a cramped sitting room with pink walls and baffling layers of mirrors. There are books of religion and poetry and paintings of Ali -- cousin of the prophet Muhammad and a revered figure among Shiites -- and his trusty sword, Zulfiqar.
In the chaotic early days of the revolution, Molkara was taunted and harassed by overzealous mobs. So many transgendered people were rounded up by the regime that a special jail wing was built for them. Molkara grew depressed. "I wanted to die," she says, waves of perfume wafting from her muumuu.
Instead, she appealed to the government, working her way up the chain of clerics until she spoke with Khomeini's brother. It was he who took her to see Khomeini himself. That same day, Molkara won the right to live as a woman. On Khomeini's orders, the clerics gave her a chador and registered her as a woman in the government directories.
"It was like heaven," she remembers dreamily. "I was born again."
But it was only the beginning of Molkara's fight. She recently teamed up with sympathetic Iranian officials -- including the head of the Special Court of Clergy and the vice president for women's affairs -- to form an organization devoted to transgender rights. At her prodding, a government-linked Islamic charity named after Khomeini recently agreed to provide loans to pay for the surgeries.
Still, Molkara is not satisfied. She doesn't like the government-issue identity card that spells out her former life as a man. She doesn't like the hard-liners who've threatened her. One official even sneered that she'd tricked Khomeini, she says. In short, she is hoping to push transgenders even further into the Iranian mainstream.
"Nobody ever asks why a dog is a dog," she says. "And yet they always have to explain that I was once a man."