"And Amalek came and fought with Israel" (Exodus 17:8). Rabbi Elazar ben Hisma says: This verse is marked out and explained by Job, as it is said, "Can the papyrus grow up without a marsh?" and so on (Job 8:11). Just as that is impossible, so it is impossible for Israel to live unless they occupy themselves with words of Torah. And because Israel had separated themselves from the words of Torah, therefore the enemy came upon them. And the enemy never comes except on account of sin and on account of transgression. Therefore it is said, "And Amalek came." Rabbi Yehuda the Patriarch says: Amalek stepped past five nations and came and made war with Israel at Rephidim, as it is said, "Amalek dwells in the land of the Negev, and the Hittite and the Jebusite and the Amorite dwell in the hill country, and the Canaanite dwells by the sea and along the Jordan" (Numbers 13:29). From here you learn that Amalek was inward of them all. Rabbi Natan says: He came from the mountains of Seir and traveled four hundred parasangs until he reached Rephidim and made war with Israel. Others say: Let Amalek the ingrate come and exact punishment from an ingrate people. And thus it says, "And these are the ones who conspired against him: Zabad son of Shimath the Ammonitess and Jehozabad son of Shimrith the Moabitess" (2 Chronicles 24:26). Let these ingrates come and exact punishment from Joash the ingrate, as it is said, "And Joash the king did not remember the kindness that Jehoiada his father had done with him, and he killed his son; and as he died he said, May the LORD see and require it" (2 Chronicles 24:22). And what was his punishment? "And it happened at the turn of the year that the army of Aram went up against him, and they came to Judah and Jerusalem and destroyed all the officers of the people from among the people" and so on. "And against Joash they executed judgments" (2 Chronicles 24:23-24). Do not read "judgments" (shefatim), but rather "abusings" (shipputim). Cruel ruffians who did not know the lying with a woman rose up against him and tormented him with the lying of males, as it is said, "And the pride of Israel testifies to his face" (Hosea 7:10). And it is written, "And when they departed from him, for they left him in great diseases, his servants conspired against him for the blood of the sons of Jehoiada the priest, and slew him on his bed, and he died; and they buried him in the city of David, but they did not bury him in the tombs of the kings" (2 Chronicles 24:25). "And he fought with Israel at Rephidim" (Exodus 17:8). Rabbi Hananyah said: I asked Rabbi Eliezer: What did Israel see fit to redeem the firstborn of donkeys and not to redeem the firstborn of horses and camels? He said to me: It is a decree of the King, for they had nothing in their possession but donkeys. For there was not a single one of Israel who did not bring up with him ninety donkeys laden with silver and gold and garments. Others say: Rephidim means nothing other than that they slackened their hands from the Torah, and therefore Amalek came upon them. And thus you find that the enemy comes only by reason of the slackening of hands from the Torah, as it is said, "And it came to pass, when the kingdom of Rehoboam was established and he had grown strong, that he forsook the Torah of the LORD, and all Israel with him" (2 Chronicles 12:1). And what was his punishment? "Shishak king of Egypt went up against Jerusalem and took all the shields of gold that Solomon had made" (1 Kings 14:25-26).
Then Came Amalek and Fought with Israel in Rephidim
Midrash Tanchuma, Beshalach 25
וַיָּבֹא עֲמָלֵק וַיִּלָּחֶם עִם יִשְׂרָאֵל. רַבִּי אֶלְעָזָר בֶּן חִסְמָא אוֹמֵר: מִקְרָא זֶה רָשׁוּם וּמְפֹרָשׁ הוּא עַל יְדֵי אִיּוֹב, שֶׁנֶּאֱמַר: הֲיִגְאֶה גֹּמֶא בְּלֹא בִצָּה וְגוֹ' (איוב ח, יא). כְּשֵׁם שֶׁאִי אֶפְשָׁר, כָּךְ אִי אֶפְשָׁר לְיִשְׂרָאֵל לִחְיוֹת אֶלָּא אִם כֵּן מִתְעַסְּקִין בְּדִבְרֵי תּוֹרָה. וּלְפִי שֶׁפֵּרְשׁוּ יִשְׂרָאֵל מִדִּבְרֵי תּוֹרָה, לְפִיכָךְ הַשּׂוֹנֵא בָּא עֲלֵיהֶם. וּלְעוֹלָם אֵין הַשּׂוֹנֵא בָּא אֶלָּא עַל הַחֵטְא וְעַל הָעֲבֵרָה. לְכָךְ נֶאֱמַר וַיָּבֹא עֲמָלֵק. רַבִּי יְהוּדָה הַנָּשִׂיא אוֹמֵר: חֲמִשָּׁה עֲמָמִים פָּסַע עֲמָלֵק וּבָא וְעָשָׂה מִלְחָמָה עִם יִשְׂרָאֵל בִּרְפִידִים, שֶׁנֶּאֱמַר: עֲמָלֵק יוֹשֵׁב בְּאֶרֶץ הַנֶּגֶב וְהַחִתִּי וְהַיְבוּסִי וְהָאֱמֹרִי יוֹשֵׁב בָּהָר וְהַכְּנַעֲנִי יוֹשֵׁב עַל הַיָּם וְעַל יַד הַיַּרְדֵּן (במדבר יג, כט). מִכָּאן אַתְּ לָמֵד, שֶׁהָיָה עֲמָלֵק לִפְנִים מִכֻּלָּן. רַבִּי נָתָן אוֹמֵר: מֵהַרְרֵי שֵׂעִיר בָּא וְהָלַךְ אַרְבַּע מֵאוֹת פַּרְסָה עַד שֶׁהִגִּיעַ לִרְפִידִים וְעָשָׂה עִם יִשְׂרָאֵל מִלְחָמָה. אֲחֵרִים אוֹמְרִים: יָבוֹא עֲמָלֵק כְּפוּי טוֹבָה וְיִפָּרַע מֵעַם כְּפוּי טוֹבָה. וְכֵן הוּא אוֹמֵר: וְאֵלֶּה הַמִּתְקַשְּׁרִים עָלָיו זָבָד בֶּן שִׁמְעָת הָעַמּוֹנִית וִיהוֹזָבָד בֶּן שִׁמְרִית הַמּוֹאָבִית (דה״ב כד, כו). יָבוֹאוּ אֵלּוּ כְּפוּיֵי טוֹבָה וְיִפָּרְעוּ מִיּוֹאָשׁ כְּפוּי טוֹבָה, שֶׁנֶּאֱמַר: וְלֹא זָכַר יוֹאָשׁ הַמֶּלֶךְ הַחֶסֶד אֲשֶׁר עָשָׂה יְהוֹיָדָע אָבִיו עִמּוֹ וַיַּהֲרֹג אֶת בְנוֹ וּכְמוֹתוֹ אָמַר יֵרֶא ה' וְיִדְרֹשׁ (דה״ב כד, כב). וּמַה הוּא עָנְשׁוֹ? וַיְהִי לִתְקוּפַת הַשָּׁנָה עָלָה עָלָיו חֵיל אֲרָם וַיָּבֹאוּ אֶל יְהוּדָה וִירוּשָׁלַיִם וַיַּשְׁחִיתוּ אֶת כָּל שָׂרֵי הָעָם מֵעָם וְגוֹ'. וְאֶת יוֹאָשׁ עָשׂוּ שְׁפָטִים (דה״ב כד, כג כד). אַל תְּהִי קוֹרֵא שְׁפָטִים, אֶלָּא שִׁפּוּטִים. עָמְדוּ עָלָיו בִּרְיוֹנִים קָשִׁים שֶׁלֹּא יָדְעוּ מִשְׁכַּב אִשָּׁה וְעִנּוּ אוֹתוֹ בְּמִשְׁכַּב זָכוּר, שֶׁנֶּאֱמַר: וְעָנָה גְאוֹן יִשְׂרָאֵל בְּפָנָיו (הושע ז, י). וּכְתִיב: וּבְלֶכְתָּם מִמֶּנּוּ כִּי עָזְבוּ אֹתוֹ בְּמַחֲלֻיִים רַבִּים הִתְקַשְּׁרוּ עָלָיו עֲבָדָיו בִּדְמֵי בְּנֵי יְהוֹיָדָע הַכֹּהֵן וַיַּהַרְגֻהוּ עַל מִטָּתוֹ וַיָּמֹת וַיִּקְבְּרֻהוּ בְּעִיר דָּוִיד וְלֹא קְבָרֻהוּ בְּקִבְרוֹת הַמְּלָכִים (דה״ב כד, כה). וַיִּלָּחֶם עִם יִשְׂרָאֵל בִּרְפִידִם אָמַר רַבִּי חֲנַנְיָה: שָׁאַלְתִּי אֶת רַבִּי אֱלִיעֶזֶר: מָה רָאוּ יִשְׂרָאֵל לִפְדּוֹת פִּטְרֵי חֲמוֹרִים וְלֹא לִפְדּוֹת פִּטְרֵי סוּסִים וּגְמַלִּים? אָמַר לִי: גְּזֵרַת מֶלֶךְ הִיא, שֶׁלֹּא הָיָה בְּיָדָם אֶלָּא חֲמוֹרִים. שֶׁאֵין לְךָ כָּל אֶחָד וְאֶחָד מִיִּשְׂרָאלֵ, שֶׁלֹּא עָלָה עִמּוֹ תִּשְׁעִים חֲמוֹרִים טְעוּנִין כֶּסֶף וְזָהָב וּשְׂמָלוֹת. אֲחֵרִים אוֹמְרִים: אֵין רְפִידִים אֶלָּא שֶׁרָפוּ יְדֵיהֶם מִן הַתּוֹרָה, וּלְפִיכָךְ עֲמָלֵק בָּא עֲלֵיהֶם. וְכֵן אַתְּ מוֹצֵא, שֶׁאֵין הַשּׂוֹנֵא בָּא אֶלָּא עַל יְדֵי רִפְיוֹן יָדַיִם מִן הַתּוֹרָה, שֶׁנֶּאֱמַר: וַיְהִי כְּהָכִין מַלְכוּת רְחַבְעָם וּכְחֶזְקָתוֹ עָזַב אֶת תּוֹרַת ה' וְכָל יִשְׂרָאֵל עִמּוֹ (דה״ב יב, א). וּמֶה עָנְשׁוֹ? עָלָה שִׁישַׁק מֶלֶךְ מִצְרַיִם עַל יְרוּשָׁלָיִם, וַיִּקַּח אֶת כָּל מָגִנֵּי הַזָּהָב אֲשֶׁר עָשָׂה שְׁלֹמֹה (מלכים א יד, כה-כו).