An 18-year-old Iranian is facing imminent execution on charges of homosexuality, even though he has no legal representation. Ebrahim Hamidi, who is not gay, was sentenced to death for lavat, or sodomy, on the basis of "judge's knowledge", a legal loophole that allows for subjective judicial rulings where there is no conclusive evidence. Hamidi had been represented by human rights lawyer Mohammad Mostafaei, who has since been forced to flee Iran after bringing to international attention the case of another of his clients, Sakineh Mohammadi Ashtiani, a 43-year-old Iranian mother of two who has been sentenced to death by stoning for adultery. Mostafaei was due to arrive in Norway yesterday to begin a life in exile while continuing his campaigns on behalf of his clients, including Hamidi.

At the same time, human rights activist Peter Tatchell has written to the foreign secretary, William Hague, urging him to contact the chief justice of Iran and ask that the execution be halted.

"Ebrahim's case is evidence that innocent heterosexual people can be sentenced to death on false charges of homosexuality [in Iran]," said Tatchell, co-founder of the London-based gay rights group OutRage.

Hamidi was arrested two years ago in the suburbs of the western city of Tabriz in the East Azerbaijan province after a fight with members of another family. Three of his friends were also involved in the incident and were subsequently arrested. Later, the four were accused of homosexual assault on a man and of attempting to abuse him sexually.

A person convicted of homosexuality in Iran can be lashed, hanged or stoned to death. The law includes a variety of penalties for different acts: 99 lashes if two unrelated males sleep "unnecessarily" under the same blanket – even without any sexual contact. A boy raped by an adult man would also be lashed if the court decided that he had "enjoyed" the experience.

After three days in detention, Hamidi confessed to the crime, allegedly under torture. The other three were cleared of all charges when promised by officials that they would be freed if they testified against Hamidi.

However, last month Hamidi's alleged victim admitted that he had been under pressure from his parents to make false accusations. Nevertheless the local judiciary has insisted that Hamidi should be executed.

Mostafaei initially wrote an open letter about Hamidi's case to highlight the execution of juvenile offenders. But two weeks ago Mostafaei's wife, Fereshteh Halimi, was arrested and had been kept in solitary confinement in Tehran's notorious Evin prison without charge until late last night, when the Observer understood that she was released.

Mostafaei fled to Turkey, where he was promptly arrested for entering the country illegally. On Friday, however, the Turkish authorities released him after EU diplomats intervened on his behalf. As he left, Mostafaei had repeated his fears for his wife's safety. "They've taken her in as a hostage; it's kidnapping," he told the Observer. "Just look at what is happening to my wife and realise the flaws and failings of the Iranian legal system, especially towards Ebrahim Hamidi and Sakineh Mohammadi Ashtiani, who are awaiting execution on basis of false accusations," he added.

Mostafaei, whose office in Tehran is now sealed off, is credited with saving at least 50 people from execution during his career, among them many juvenile offenders. A recent client, Ali Mahin-Torabi, 21, was released in July after Mostafaei's efforts commuted his death sentence. With Mostafaei exiled, activists are worried for Hamidi. "It's shocking that although Hamidi's accuser admitted in a recorded testimony that he had lied, he is still facing execution," Mostafaei said.

An online petition calling for the execution order to be rescinded was launched on 8 August.