When a couple experiences difficulty conceiving, sometimes it is necessary to conduct a semen analysis to determine whether there is male factor infertility. Other times it is necessary for the man to provide sperm for the purpose of IVF or IUI (intrauterine insemination), a procedure in which his sperm is injected into his wife’s uterus.
To collect this sperm, the husband should have sexual relations with his wife while wearing a condom. The condom must be a special one, without any spermicide (as that would obviously interfere with the test results). It should also have a tiny hole in it, so that it is possible for some sperm to escape. That way, according to all poskim, there is no prohibition of wasting seed.
A regular condom may be used in two circumstances: when no condom with a small hole is available, and when the sperm being collected is for IVF which is being done to prevent genetic diseases. (In this case, one does not want any sperm to reach the woman’s uterus, as this may lead to the birth of a baby with the disease.) It would seem that all poskim would agree in these cases as well.
When having relations with a condom is impossible, for example in a case where the sample must be brought to the lab almost immediately, most poskim permit the wife to stimulate her husband manually, to enable him to ejaculate into a condom or container used for that purpose. It is possible that all would agree to this as well.
Because of the severity of the prohibition of wasting seed, some maintain that when this is necessary to determine the reason for infertility, all possible tests must be conducted on the woman before the man may provide a sperm sample. In practice, all tests that can easily be performed on the woman should be done first. After that it is permissible to conduct the necessary tests on the man, because as long as the wife helps her husband produce the sample, it is considered part of the fulfillment of the mitzva.
When a couple cannot have relations using a condom, and the wife cannot help her husband ejaculate because she is a nidda, according to most poskim the man may ejaculate into a container. Others do not allow it. In practice, when there is no other option, one may be lenient.
Poskim disagree regarding a case in which a man cannot ejaculate without direct stimulation. Would it be permissible for him to stimulate himself manually to provide sperm for analysis or for fertilizing his wife’s eggs? Some prohibit this, including Rav Kook (Ezrat Kohen §32), R. Feinstein (Igrot Moshe, EH 1:70 and 2:16), and R. Elyashiv (Kovetz Teshuvot 3:189). Others permit it, including R. Grodzinski (Aḥiezer 3:24:4) and R. Uziel (Mishpetei Uziel, EH 2:42). The latter explains that in the case in the Talmud, the purpose was to see if sperm would seep out of the puncture. If the man were holding himself, it would be difficult to determine this. However, had there not been a practical necessity to avoid manual stimulation, it would have been permissible in the service of procreation. This is also the approach of R. Waldenberg (Tzitz Eliezer 9:51, sha’ar 1, 2:2) and R. Daichovsky (Teḥumin 18). See below, section 4 and n. 4, where we discuss the law pertaining to a young man who has cancer and must undergo radiation treatments that may render him infertile. Before he undergoes such treatments, it is a mitzva for him to produce sperm to freeze, so that when he gets married he will be able to fulfill the mitzva of procreation.
It would seem that this disagreement is based on how one understands the underlying reason for the prohibition of wasting seed. If it is prohibited because it contains an element of adultery (Or Zaru’a 1:124; Smak §292) or because it involves sinful thoughts (Baḥ 3:6), then masturbating might be prohibited even for the sake of a mitzva. However, according to the opinion of Tosafot (Sanhedrin 59b s.v. “ve-ha”) that the prohibition of wasting seed is an extension of the mitzva of procreation, clearly it is permissible to provide sperm in order to solve fertility issues. Similarly, according to those who maintain that the prohibition is derived from the story of Er and Onan, who were trying to avoid having children (Pri Megadim, Eshel Avraham 31:14; Ben Yehoyada, Nidda 13a), the prohibition would not apply to masturbating for the purpose of having children. According to those who maintain that the prohibition of wasting seed stems from the prohibition of wasteful destruction (R. Yaakov Ettlinger, Arukh La-ner, Nidda 13b and Binyan Tziyon §137), then in this case, where clearly the purpose is to be productive, there is no problem.
In practice, it seems that it is permitted. First, some maintain that the whole prohibition of wasting seed is rabbinic, as explained above in ch. 4, n. 1. Furthermore, when the production of semen is for the sake of performing the mitzva of procreation, even those who are stringent would concede that the prohibition is rabbinic. When there is disagreement concerning a rabbinic law, halakha follows the lenient position. Moreover, the reasoning of those who are lenient is persuasive. Furthermore, in pressing circumstances and when extremely necessary, we rule leniently. It is also possible that if those who were stringent in the past had known that these tests had a reasonable chance of enabling a couple to fulfill the mitzva of procreation, they would have been lenient. Doctors then were fumbling around in the dark. Since a procedure was only a shot in the dark, some poskim did not permit masturbation to enable it. Now that success rates are so much higher, it is permitted even for a couple who have already fulfilled the Torah commandment. Nevertheless, testing the wife should be done first, because this involves no possible prohibitions. However, if a test is extremely difficult for the woman or very expensive, then her husband can provide semen for analysis before she undergoes it.
All this refers to a case in which a man stimulates himself manually and ejaculates into a container. However, if his wife helps him ejaculate by embracing or touching him, it is possible that everyone would agree that this is permitted, since it involves no element of adultery or sinful thoughts. With respect to the problem of the ejaculation being non-procreative at the time, we know that some Rishonim (Orḥot Ḥayim, Hilkhot Ketubot §7; Rabbeinu Yona on Sanhedrin 58b; Tur, EH 25:2) permit intercourse with other parts of the body (i.e., non-vaginal and non-anal). Rambam seems to permit it as well (MT, Laws of Sexual Prohibitions 21:9). Rema rules in practice: “Even though doing all of these is permissible, anyone who sanctifies himself [by refraining from] what is permitted to him is considered holy” (EH 25:2). In our case, when the husband is producing sperm to enable fulfillment of the mitzva of pru u-revu, it is a mitzva for him to do so. This would also seem to be the opinion of R. Shlomo Zalman Auerbach (Nishmat Avraham, EH 23:2, n. 1). In my humble opinion, when his wife helps him, it is unnecessary for her to undergo all sorts of tests before her husband provides a sperm sample, though if they can be done easily, it is preferable.
It is even better if the couple has relations using a condom. There is absolutely nothing wrong with this, nor is any seed being wasted, as the entire point is to fulfill the mitzva of procreation. It is better yet when the condom has a hole, so that it is possible for a drop of semen to escape and possibly impregnate the wife. However, when it is difficult to acquire such a condom, or when the objective of using the condom is to prevent the transmission of genetic diseases, it is certainly permissible to have relations with a standard condom. It would seem that all poskim would agree with this.