The ayatollah replied that his case was different from that of a homosexual and therefore he had his blessing.

However, the revolution intervened and men like himself or those who had already changed their sex were harassed, even jailed and tortured. ''They made me stop wearing women's clothes, which I had worn for many years and was used to,'' Ms. Molkara recalled. ''It was like torture for me. They even made me take hormones to look like a man.''

It took him eight years after the revolution, in 1986, to get government permission to proceed with surgery. But he could not afford the surgery and did not have it until 1997, when he underwent a sex-change operation in Bangkok. The Iranian government covered the expenses. Four years ago, Ms. Molkara established an organization to help those with gender-identity problems. Co-founders include Ali Razini, head of the Special Court of Clergy, a branch of the judiciary that only deals with clerics, and Zahra Shojai, Iran's vice president for women's affairs. An Islamic philanthropic group known as the Imam Khomeini Charity Foundation has agreed to provide loans equivalent to about $1,200 to help pay for sex-change surgery.

To obtain legal permission for sex-change operations and new birth certificates, applicants must provide medical proof of gender-identity disorder. The process can take years.

It also involves considerable expense. In Tehran, the initial male-to-female surgery runs about $4,000. So far, Amir has spent $12,000 on medical procedures.

The people who pursue this route come from many different backgrounds.

Dr. Bahram Mir-djalali, one of Tehran's few sex-reassignment surgeons, said one of his patients had been a member of the Revolutionary Guards who served five years in the war with Iraq. His operation was paid for by a Muslim cleric he had worked for as a secretary. After the surgery, the man-turned-woman divorced, and then married the cleric.

''When she came to see me years later, she was wearing a chador,'' the doctor recalled, referring to the black head-to-toe garb worn by religious women. ''She took off the chador, and there was no sign of the bearded man I had operated on.''