Iran has a long History of Persecution of Homosexuals. This Homophobia dates back to Zoroastrianism, one of the oldest religions in the world. Even today Iran is one of few countries in the world which can legally execute gays.
Avesta is primary text of Zoroastanism.Avesta orders one of the most severe form of Persecution of Homosexuals. If a Person commits homosexuality willingly, then there is no penance for it. He should be put to death and anyone can kill him without the order of Judiciary. Even if the person is forced to commit sodomy(in other word raped), the penalty of 800 stripes apply on him. Probably in Ancient Persia were very strong to sustain pain of 800 stripes.
Reference: AVESTA>> Vendidad>> FARGARD : 8 Funerals and purification, unlawful sex>>V Unlawful lusts>> Verse: 26-32
Online Source: http://www.avesta.org/vendidad/vd8sbe.htm
26. O Maker of the material world, thou Holy One! If a man, by force, commits the unnatural sin [sodomy], what is the penalty that he shall pay?
Ahura Mazda answered: ‘Eight hundred stripes with the Aspahe-astra, eight hundred stripes with the Sraosho-charana.’
27. O Maker of the material world, thou Holy One! If a man voluntarily commits the unnatural sin, what is the penalty for it? What is the atonement for it? What is the cleansing from it?
Ahura Mazda answered: ‘For that deed there is nothing that can pay, nothing that can atone, nothing that can cleanse from it; it is a trespass for which there is no atonement, for ever and ever.’
28. When is it so?
‘It is so if the sinner be a professor of the Religion of Mazda, or one who has been taught in it.
‘But if he be not a professor of the Religion of Mazda, nor one who has been taught in it, then his sin is taken from him, if he makes confession of the Religion of Mazda and resolves never to commit again such forbidden deeds.
29. ‘The Religion of Mazda indeed, O Spitama Zarathushtra! takes away from him who makes confession of it the bonds of his sin; it takes away (the sin of) breach of trust; it takes away (the sin of) murdering one of the faithful; it takes away (the sin of) burying a corpse; it takes away (the sin of) deeds for which there is no atonement; it takes away the worst sin of usury; it takes away any sin that may be sinned.
30. In the same way the Religion of Mazda, O Spitama Zarathushtra! cleanses the faithful from every evil thought, word, and deed, as a swift-rushing mighty wind cleanses the plain.
‘So let all the deeds he doeth be henceforth good, O Zarathushtra! a full atonement for his sin is effected by means of the Religion of Mazda.’
31. O Maker of the material world, thou Holy One! Who is the man that is a Daeva? Who is he that is a worshipper of the Daevas? that is a male paramour of the Daevas? that is a female paramour of the Daevas? that is a wife to the Daeva34? that is as bad as a Daeva: that is in his whole being a Daeva? Who is he that is a Daeva before he dies, and becomes one of the unseen Daevas after death35
32. Ahura Mazda answered: ‘The man that lies with mankind as man lies with womankind, or as woman lies with mankind, is the man that is a Daeva; this one is the man that is a worshipper of the Daevas, that is a male paramour of the Daevas, that is a female paramour of the Daevas, that is a wife to the Daeva; this is the man that is as bad as a Daeva, that is in his whole being a Daeva; this is the man that is a Daeva before he dies, and becomes one of the unseen Daevas after death: so is he, whether he has lain with mankind as mankind, or as womankind36
36. [i.e. the recipient is equally guilty. -JHP] The guilty may be killed by any one, without an order from the Dastur (see § 74 n.), and by this execution an ordinary capital crime may be redeemed (Comm. ad Vd7.52).
55. ‘He who burns Nasu (dead matter) must be killed. Burning or cooking Nasu from the dead is a capital crime. . . . Four men can be put to death by anyone without an order from the Dastur: the Nasu-burner, the highwayman, the Sodomite, and the criminal taken in the deed’ (Comm.)