The Gemara presents the sin of the generation of the dispersion and related punishments, portraying Babel as a paradigmatic collective rebellion. It gives a broader Chazal frame for the episode behind Rashi's first and second explanations.
דּוֹר הַפְּלַגָּה אֵין לָהֶם חֵלֶק לָעוֹלָם הַבָּא וְכוּ׳. מַאי עֲבוּד? אָמְרִי דְּבֵי רַבִּי שֵׁילָא: נִבְנֶה מִגְדָּל וְנַעֲלֶה לָרָקִיעַ, וְנַכֶּה אוֹתוֹ בְּקַרְדּוּמּוֹת כְּדֵי שֶׁיָּזוּבוּ מֵימָיו. מַחֲכוּ עֲלַהּ בְּמַעְרְבָא: אִם כֵּן, לִיבְנוֹ אַחַד טוּרָא! (אֶלָּא) אָמַר רַבִּי יִרְמְיָה בַּר אֶלְעָזָר: נֶחְלְקוּ לְשָׁלֹשׁ כִּיתּוֹת, אַחַת אוֹמֶרֶת: נַעֲלֶה וְנֵשֵׁב שָׁם, וְאַחַת אוֹמֶרֶת: נַעֲלֶה וְנַעֲבוֹד עֲבוֹדָה זָרָה, וְאַחַת אוֹמֶרֶת: נַעֲלֶה וְנַעֲשֶׂה מִלְחָמָה. זוֹ שֶׁאוֹמֶרֶת נַעֲלֶה וְנֵשֵׁב שָׁם – ״הֱפִיצָם ה׳״, וְזוֹ שֶׁאוֹמֶרֶת נַעֲלֶה וְנַעֲשֶׂה מִלְחָמָה – נַעֲשׂוּ קוֹפִים וְרוּחוֹת וְשֵׁידִים וְלִילִין, וְזוֹ שֶׁאוֹמֶרֶת נַעֲלֶה וְנַעֲבוֹד עֲבוֹדָה זָרָה – ״כִּי שָׁם בָּלַל ה׳ שְׂפַת כׇּל הָאָרֶץ״. תַּנְיָא, רַבִּי נָתָן אוֹמֵר: כּוּלָּם לְשֵׁם עֲבוֹדָה זָרָה נִתְכַּוְּונוּ. כְּתִיב הָכָא: ״נַעֲשֶׂה לָנוּ שֵׁם״, וּכְתִיב הָתָם: ״וְשֵׁם אֱלֹהִים אֲחֵרִים לֹא תַזְכִּירוּ״. מָה לְהַלָּן עֲבוֹדָה זָרָה, אַף כָּאן עֲבוֹדָה זָרָה.
§ The mishna teaches that the members of the generation of the dispersion have no share in the World-to-Come. The Gemara asks: What sin did they perform? Their sin is not explicitly delineated in the Torah. The school of Rabbi Sheila say that the builders of the Tower of Babel said: We will build a tower and ascend to heaven, and we will strike it with axes so that its waters will flow. They laughed at this explanation in the West, Eretz Yisrael, and asked: If that was their objective, let them build a tower on a mountain; why did they build it specifically in a valley (see Genesis 11:2)? Rather, Rabbi Yirmeya bar Elazar says: They divided into three factions; one said: Let us ascend to the top of the tower and dwell there. And one said: Let us ascend to the top of the tower and engage in idol worship. And one said: Let us ascend to the top of the tower and wage war. With regard to that faction that said: Let us ascend to the top of the tower and dwell there, God dispersed them. And that faction that said: Let us ascend to the top of the tower and wage war, became apes, and spirits, and demons, and female demons. And with regard to that faction that said: Let us ascend to the top of the tower and engage in idol worship, it is written: “Because there the Lord confounded the language of all the earth” (Genesis 11:9). It is taught in a baraita: Rabbi Natan says: All of those factions intended to build the tower for the sake of idol worship. It is written here: “And let us make a name for us” (Genesis 11:4), and it is written there: “And make no mention of the name of the other gods” (Exodus 23:13). Just as there, the connotation of “name” is idol worship, so too here, the connotation of “name” is idol worship.