(Deuteronomy 12:29:) "When the LORD your God cuts off the nations." A parable: To what is the matter comparable? To a king who planted a vineyard in the midst of his field, and within it were great cedars and thorns. The king went and cut down the cedars and left the thorns. His servants said to him: Our lord the king, you have left the thorns, which catch in our garments, but you have cut down the cedars! He said to them: If I had left the cedars and cut down the thorns, with what would I have fenced in my vineyard? And so too Israel is the vineyard of the Holy One, blessed be He, as it is said (Isaiah 5:7): "For the vineyard of the LORD of hosts is the house of Israel." He brought Israel into the land and cut down the cedars that were in it, as it is said (Amos 2:9): "Yet I destroyed the Amorite before them, whose height was like the height of the cedars." But He left their children and their children's children, so that Israel would keep the Torah, as it is said (Judges 3:1): "Now these are the nations which the LORD left, to test Israel by them." And when the vineyard stands in its place in the keeping of the Torah, then (Isaiah 33:12): "And the peoples shall be as the burnings of lime, as thorns cut down, [that are burned in the fire]." And it is written (Isaiah 40:17): "All the nations are as nothing before Him." See how many multitudes Pharaoh sent out after Israel! When Israel saw them, they were terrified before them and said: Who can stand against these? The Holy One, blessed be He, said to them: By your lives, all of these are accounted before Me as nothing [but] a single horse, as it is said (Exodus 15:19): "For the horse of Pharaoh came." And they all died with a single breath, as it is said (Exodus 15:10): "You blew with Your wind." So too, Gog and Magog are destined to come against Israel, and against him the Holy One, blessed be He, will execute His judgments, as it is said (Ezekiel 38:22): "And I will enter into judgment with him with pestilence and with blood." At that hour (Ezekiel 38:23): "Thus will I magnify Myself, and sanctify Myself, [and make Myself known] in the eyes of many nations, and they shall know that I am the LORD."
The Vineyard of Israel and the Cedars God Cut Down
Midrash Tanchuma Buber, Re'eh 3:1
כי יכרית ה' אלהיך את הגוים (דברים יב כט). משל למה הדבר דומה, למלך שנטע כרם בתוך שדהו, והיה בתוכו ארזים גדולים וקוצים, הלך המלך וקיצץ את הארזים, והניח את הקוצים, אמרו לו עבדיו אדונינו המלך הקוצים שהם אוחזים בבגדינו הנחת, וקיצצת את הארזים, אמר להם אם הנחתי את הארזים, וקצצתי את הקוצים, במה הייתי (גוזר) [גודר] את כרמי, וכן ישראל כרמו של הקב"ה, שנאמר כי כרם ה' צבאות בית ישראל (ישעיה ה ז), והכניס את ישראל לארץ, וקיצץ את הארזים שבה, שנאמר ואנכי השמדתי את האמורי [מפניהם אשר כגובה ארזים גבהו] (עמוס ב ט), והניח את בניהם, ואת בני בניהם, כדי שישמרו ישראל את התורה, שנאמר ואלה הגוים אשר הניח ה', לנסות בם את ישראל (שופטים ג א), וכשיעמוד הכרם על עמדו במשמרת התורה, והיו עמים משרפות סיד קוצים כסוחים וגו' (ישעיה לג יב), וכתיב כל הגוים כאין נגדו (שם מ יז), ראה כמה אוכלוסין הוציא פרעה אחרי ישראל, כשראו אותם ישראל נבהלו מפניהם ואמרו מי יוכל לעמוד כנגד אלו, אמר הקב"ה חייכם כל אלו אינן חשובין לפני [רק] כסוס אחד, שנאמר כי בא סוס פרעה (שמות טו יט), וכולם מתו בנשיפה אחת, שנאמר נשפת ברוחך (שם שם י), כך עתיד גוג ומגוג לבוא על ישראל, ובו יעשה הקב"ה משפטיו, שנאמר ונשפטתי (אותו) [אתו] בדבר ובדם וגו' (יחזקאל לח כב), באותה שעה והתגדלתי והתקדשתי [ונודעתי] לעיני (עמים) [גוים] רבים וידעו כי אני ה' (שם שם כג).