and their contentions are like the bars of a castle” (Proverbs 18:19)? “A brother offended is harder to be won than a strong city,” this is Lot, called Abraham’s brother (see Genesis 14:14), who separated from Abraham. “And their contentions are like the bars of a castle,” this is because Lot brought contention between the Jewish people and his own descendants like bars, which lock the gates of a castle. Just as no one can enter a locked castle, so too Lot’s descendants, Ammon and Moab, were prevented from joining the Jewish people, as it states: “An Ammonite and a Moabite should not enter into the assembly of YHWH” (Deuteronomy 23:4).
דרש רבא ואיתימא רבי יצחק: מאי דכתיב ״לתאוה יבקש נפרד ובכל תושיה יתגלע״? ״לתאוה יבקש נפרד״ — זה לוט, ״ובכל תושיה יתגלע״ — שנתגלה קלונו בבתי כנסיות ובבתי מדרשות. דתנן: עמוני ומואבי אסורין, ואיסורן איסור עולם.
On the same issue, Rava expounded a verse homiletically, and some say it was R' Yitzḥak: What is the meaning of that which is written: “He who separates himself seeks his own desire, and snarls against all sound wisdom” (Proverbs 18:1)? “He who separates himself seeks his own desire,” this is Lot, who separated from Abraham. “And snarls [yitgala] against all sound wisdom,” this too describes Lot, as his shame was eventually revealed [nitgala] in the synagogues, when his actions recorded in the Torah are read in public, and in the study halls, where the halakhot of his descendants are taught. As we learned in a Mishnah: An Ammonite and a Moabite are prohibited from entering the congregation by marrying a Jewish woman, and their prohibition is permanent.
אמר עולא: תמר זינתה, זמרי זינה.
§ In relation to the preceding discussion with regard to the daughters of Lot, who acted in a wanton manner for the sake of a mitzva, the Talmud cites that which Ulla said: Tamar engaged in licentious sex with her father-in-law, Judah (see Genesis, chapter 38), and Zimri ben Salu also engaged in licentious sex with a Midianite woman (see Numbers, chapter 25).