Two kinds of sinful thoughts are prohibited: thoughts about adultery and thoughts likely to lead to nocturnal emission. The reason for both prohibitions is the same: they harm the sacred bond between spouses and divert elsewhere the desire that should be used to increase the couple’s love and devotion, causing the Shekhina to leave them.
The first prohibition is that a man may not think about sinning, that is, he may not imagine himself committing adultery with a woman other than his wife, and certainly he may not plan the sin in his mind. 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 heart” to refer to apostasy (idolatry or heresy) and “your eyes” to refer to sinful thoughts (Berakhot 12b). Therefore, a man may not gaze at women or their clothes in a way that is liable to lead him to sinful thoughts (SA EH 21:1). In addition to the fact that the thoughts themselves are forbidden because they damage the love between husband and wife and contaminate his thoughts with forbidden things, they are liable to lead him to actual adultery. That sin starts with lustful thoughts, whose intensification gives the sinful impulse control over the person, causing him to commit adultery. The Sages say that sinful thoughts are more serious than the sin itself (Yoma 29a). True, the punishment is more severe for committing the sin than for thinking about it. However, it is the sinful thoughts that cause a person to betray his covenant with his wife and commit adultery. These thoughts begin before and persist after the sin, thus further defiling the mind and soul.
One of the reasons that the Sages instituted “Va-yomer” as the third paragraph of the daily recitation of Shema is to remind people to guard themselves against sinful thoughts. This paragraph contains the verse, “Do not follow your heart and your eyes, by which you are led astray,” and also records the mitzva of wearing tzitzit, for by remembering the tzitzit, a person can be saved from sin (Menaḥot 44a; above, 3:6).
The second prohibition is for a man to think about anything that sexually stimulates him and may cause him to have a nocturnal emission or “wet dream,” that is, to ejaculate while sleeping. The Torah says, “Stay away from every evil thing” (Devarim 23:10), which the Sages explain to mean, “A man must not entertain thoughts during the day that will cause him to become impure at night” (Avoda Zara 20b). This prohibition includes thinking about, reading, or looking at anything that arouses his urges and causes an erection, even if the man does not actually imagine himself with a woman who is forbidden to him. Even a married man, when he is away from his wife, or when she is a nidda, may not think about being intimate with her in a sexually stimulating way, as it can lead to a nocturnal emission. All his desire must be safeguarded for his wife alone.
A nocturnal emission is called keri or tuma. The word “keri” is used because it occurs unintentionally, by chance (be-mikreh) at night (layla). Thus, it is also referred to as a “mikreh layla.” The word “tuma” is used because a nocturnal emission makes a person impure; he may neither ascend the Temple Mount nor eat taharot (food that must be eaten while one is ritually pure). To purify himself, he must immerse in a mikveh. Then, after the sun sets, he may eat taharot (see 3:8 above).
A nocturnal emission happens due to a combination of a natural process – such as the body’s production of semen – and the waking thoughts that a man has that cause him to get an erection. Even if he successfully controls himself during the day and does not masturbate, these thoughts return in his dreams and cause a nocturnal emission. Nevertheless, even the righteous who control their thoughts during the day occasionally experience a seminal emission, because this is the way a man’s body works. It constantly produces semen; as time goes by and semen builds up, the body becomes aroused to ejaculate. This happens more frequently with younger men than older men. (The prohibition of sinful thoughts and masturbation for women is explained below, in sections 10-12.)
. Many poskim say that if a man thinks about whatever is likely to cause him a nocturnal emission, he violates a Torah prohibition. They understand the Sages’ interpretation of Devarim 23:10 to be a bona fide expounding of the verse (Smag, Lo Ta’aseh 126; Smak §24; Ran on Ḥullin 37b; Beit Shmuel 21:2). In contrast, Yere’im §45 understands the prohibition to be rabbinic. Pri Megadim, Ezer Mi-kodesh, and Aḥiezer 3:24:5 maintain that Rambam and SA left out this admonition because, in their opinion, this interpretation is an asmakhta. See Otzar Ha-poskim 23:7-8.