If a married woman had relations with another man, or was raped and became pregnant, the resulting child is a mamzer or mamzeret and may not marry a born Jew. (Although it is permissible for a male mamzer to marry a female mamzeret and they are each allowed to marry converts, the children of these unions are also mamzerim.) The question is: may a woman abort a mamzer fetus?
R. Yair Bacharach writes that le-khatḥila she may not abort the fetus, despite the fact that Maharil writes that at the brit of a mamzer we do not recite the blessing, “preserve this child to his father and mother,” because we do not want to increase mamzerim among the Jewish people. Nevertheless, le-khatḥila, it is prohibited to harm the fetus (Responsa Ĥavot Yair §31). This implies, though, that in a case of exceptional pain and dishonor to the family, it is permissible. According to Maharit, who maintains that abortion is prohibited because of ḥavala and is permissible when there is a great need (Responsa Maharit 1:97), it seems that preventing the birth of a mamzer can be considered a great need. The eminent R. Yosef Ḥayim of Baghdad was asked whether a married woman who became pregnant from an extramarital affair could take a potion that would cause her to miscarry. He did not want to rule on the matter himself, but he copied the words of Ḥavot Ya’ir, which implies that le-khatḥila it is prohibited, and cited Maharit and She’elat Ya’avetz (1:43) as permitting an abortion in such cases (Rav Pe’alim, EH 1:4). Even though he himself did not want to decide, what he wrote suggests that he was inclined toward the lenient opinion. R. Uziel also writes that a woman may abort a mamzer (Mishpetei Uziel, ḤM 4:47).
According to those who maintain that abortion is prohibited as an offshoot of murder, aborting a mamzer is certainly prohibited. As we said in section 3, though, the primary halakhic position is the more permissive one.