"And Joshua weakened Amalek" (Exodus 17:13). Rabbi Yehoshua says: He went down and cut off the heads of the mighty men standing at the heads of the ranks. Rabbi Elazar the Modaite says: It uses a notarikon [reading the word as initials of other words] he began [vayachel], and he seized [vayochez], and he shattered [vayishaber]. "Amalek" according to its plain meaning. "The people" these are his sons. "And" [the particle et] these are the armies that were with him; these are the words of Rabbi Yehoshua. Rabbi Elazar the Modaite says: "Amalek" according to its plain meaning; "the people" these are his sons; "and" [et] these are the armies that were with him; and when it says "and" [ve-et] these are the armies that were with his sons. "By the edge of the sword." Rabbi Yehudah says: "By the edge of the sword" we learn that this war was conducted only by the command of might. Others say: "By the edge of the sword" there was fulfilled in them what is said elsewhere, "For I will make you into blood, and blood shall pursue you; if you have not hated blood, then blood shall pursue you" (Ezekiel 35:6). "And the LORD said to Moses, Write this for a memorial in the book." The first elders say: A whip with which Israel is lashed will in the end itself be lashed. Let the whole world learn from Pharaoh, that because he came and enslaved Israel, the Omnipresent drowned him in the sea, as it says, "and He shook off Pharaoh and his host into the Sea of Reeds" (Psalms 136:15). And so you find with Amalek, that because he came and harmed Israel, the Omnipresent destroyed him from this world and from the world to come, as it says, "For I will utterly blot out the memory of Amalek" (Exodus 17:14). So too every nation and kingdom that comes and harms Israel, by that very thing the Omnipresent exacts punishment from it.
Joshua Weakened Amalek and the Decree Against Israel's Oppressors
Mekhilta DeRabbi Shimon Ben Yochai 17:13
ויחלש יהושע את עמלק ר' יהושע אומר שירד וחתך ראשי גבורים העומדין בראשי שורות: ר' אלעזר המודעי אומר בו לשון נוטריקין ויחל ויאחז וישבר: עמלק. כמשמעו: עם. אלו בניו: את. אלו חיילות שעמו כך דברי ר' יהושע: ר' אלעזר המודעי אומר עמלק כמשמעו: עם. אלו בניו: את. אלו חיילות שעמו: כשהוא אומר ואת אלו חיילות שעם בניו: לפי חרב. ר' יהודה אומר לפי חרב למדנו למלחמה זו שלא היתה אלא על פי גבורה: אחרים אומרין לפי חרב נתקיים בהם מה שנאמר להלן (יחזקאל ל"ה ו') כי לדם אעשך ודם ירדפיך אם לא דם שנאת ודם ירדפך: ויאמר ה' אל משה כתוב זאת זכרון בספר זקנים הראשונים אומרין שוט שישראל לוקין בו סופו ללקות ילמד כל העולם כולו מפרעה שמתוך שבא ושעבד את ישראל טיבעו המקום בים שנ' (תהלים קל״ו ט"ו) וניער פרעה וחילו בים סוף: וכן אתה מוצא בעמלק שמתוך שבא והזיק את ישראל איבדו המקום מן העולם הזה ומן העולם הבא שנ' (פ' י"ד) כי מחה אמחה את זכר עמלק כך כל אומה ומלכות שתבא ותזיק את ישראל בו בדבר המקום נפרע ממנה: