Deuteronomy 23:2
1 A man with crushed or severed genitals may not enter the assembly of the Lord. 2 A person of illegitimate birth may not enter the assembly of the Lord; to the tenth generation no one related to him may do so. 3 No Ammonite or Moabite may enter the assembly of the Lord; to the tenth generation none of their descendants shall ever do so, 4 for they did not meet you with food and water on the way as you came from Egypt, and furthermore, they hired Balaam son of Beor of Pethor in Aram Naharaim to curse you.
Zechariah 9:6
4 Nevertheless the Lord will evict her and shove her fortifications into the sea—she will be consumed by fire. 5 Ashkelon will see and be afraid; Gaza will be in great anguish, as will Ekron, for her hope will have been dried up. Gaza will lose her king, and Ashkelon will no longer be inhabited. 6 A mongrel people will live in Ashdod, for I will greatly humiliate the Philistines. 7 I will take away their blood from their mouth and their abominations from between their teeth;9 then those who survive will become a community of believers in our God, like a clan in Judah, and Ekron will be like the Jebusites. 8 Then I will surround my temple to protect it like a guard from anyone crossing back and forth; so no one will cross over against them anymore as an oppressor, for now I myself have seen it.
Notes and References
"... In Jewish literature, the first reference to the illegitimate child or bastard (mamzer) is found in the Torah Deuteronomy 23:2: “No mamzer shall be admitted into the congregation (assembly or community) of the Lord; even to the tenth generation none of the decedents shall enter the congregation of the Lord.” No definition is given for such a person. We are not informed of his place and obligations in the Israelite nation, or of his status in the nuclear family. Does he receive an inheritance from his father? Is he obligated in mitzvoth (Jewish laws and rituals)? The Torah does not inform us of the parameters of congregation of the Lord (khal Hashem). The significance of the sanctions against the sinner is not stated. All that is clear is that the stigma and restrictions incurred by such offspring who are members of the Jewish people are transmitted genetically to future generations. In Zechariah 9:6 the word mamzer appears again; “A mamzer shall dwell in Ashdod and I will make an end to the pride of Philistia.” It is not clear if the reference is to a Jew born as a mamzer or to a member of a foreign nation. Here the mamzer is placed in a group of with the negative stance and status discussed in the prophecy of Zecharia. Implied in the passage is that this person or group will be separated from the rest of Israel and will not be part of the community of the Lord, thus supporting the assumption that the mamzer was physically separated from the clan of Israelites ..."
Fishbane, Simcha Deviancy in Early Rabbinic Literature: A Collection of Socio-Anthropological Essays (pp. 4-5) Brill, 2007