The Torah commands: “Do not lie with a male as one lies with a woman, it is a to’eva” (Vayikra 18:22). It further states: “If a man lies with a male as one lies with a woman, the two of them have done a to’eva; they shall be put to death – their blood-guilt is upon them” (ibid. 20:13). There are two ways for a man to have sexual relations with a woman: normal intercourse (“ke-darkah”), that is, vaginally; and abnormal intercourse (“she-lo ke-darkah”), i.e., anally, which is the form of intercourse between men that the Torah prohibits. The moment that penetration occurs, that is, the moment the corona of one man’s erect penis enters the other’s anus, they have both transgressed a Torah prohibition, even though the penetration was not full and there was no ejaculation. (Yevamot 55b; MT, Laws of Sexual Prohibitions 1:10; according to Taz, the Torah prohibits even penetration by part of the corona, whereas Noda Bi-Yehuda, EH 2:23 limits the Torah prohibition to penetration of the entire corona).
This prohibition is so grave that those who transgress it are liable to be punished with death by stoning, since anywhere the Torah says “their blood-guilt is upon them,” it refers to stoning (Sanhedrin 54a; Rambam ad loc. 1:6). However, this punishment applied (while the Sanhedrin functioned) only when the sin was done intentionally and in front of two witnesses who warned them of the consequences of committing the sin. In practice, almost nobody would dare to commit capital crimes in front of witnesses warning them that if they continue, they will be put to death. Therefore, an execution by the Sanhedrin rarely took place. In fact, it was so rare that a Sanhedrin which executed one person in seven years was labeled “destructive” (m. Makkot 1:10). Thus, the main purpose of the Torah declaring a death penalty is to teach us the gravity of the sin, and to deter people from brazenly transgressing it in front of witnesses.
The transgression of male homosexual intercourse is so serious that its stated punishment (stoning) is the most severe of all the death penalties. Other sexual transgressions punishable by stoning are: sexual relations between mother or stepmother and son, father and daughter or daughter-in-law, and bestiality by a man or woman (MT, Laws of Sexual Prohibitions 1:4). People who commit these sins deliberately but without witnesses are liable for karet (extirpation).
In addition to the prohibited act itself, we saw above that the Torah also prohibits thinking about committing sexual sins, as the Torah says, “Do not follow your heart and your eyes, by which you are led astray” (Bamidbar 15:39). The Sages interpret “your eyes” to mean sinful thoughts (Berakhot 12b; see section 6 above). Moreover, a man who is sexually attracted to other men must make sure that his interactions with them do not lead him to waste seed, which, according to many poskim, is a Torah prohibition (as explained in n. 1). Therefore, he should not develop a friendship for the purpose of stimulating himself sexually, because by getting himself aroused he is transgressing a rabbinic prohibition (Nidda 13b). Rather, he should behave normally with his friends, acting like everyone else, and trying to avoid arousal.