"And the LORD spoke to me, saying: You have circled this mountain long enough; turn northward. And command the people, saying" (Deuteronomy 2:2-4). This is what Scripture says: "For the leader; upon Shushan Eduth; a Mikhtam of David, to teach" (Psalms 60:1). When? "When he strove with Aram-Naharaim and with Aram-Zobah" (ibid. 60:2). But was it not already said, "[And he smote every male in Edom,] for six months Joab remained there" (1 Kings 11:16), and afterward it says, "And Joab returned and smote Edom in the Valley of Salt" (Psalms 60:2)? This is what Scripture says: "He who vindicates me is near; who will contend with me? Let us stand together" (Isaiah 50:8). The Holy One, blessed be He, gave the Torah to Israel so that through it they might prevail over all the nations. You find that Joab was head of the Sanhedrin, as it is said, "[And] these are the names of the mighty men whom David had: he who sat in the seat, wise, chief [of the three]" (2 Samuel 23:8), this is Joab; and David was wiser than all, as it is said, "And my lord is wise [like the wisdom of an angel of God]" (ibid. 14:20). And they would do nothing except by the word of the Sanhedrin, as it is said, "For the leader; upon Shushan Eduth; a Mikhtam of David" (Psalms 60:1). "Shushan Eduth", these are the Sanhedrin, as it is said, "hedged about with lilies (shoshanim)" (Song of Songs 7:3). "Eduth" (Testimony) is on account of the Torah, which is called Testimony. "Mikhtam", this is David, who made himself lowly (makh) and whole (tam), because he walked in wholeness with his Maker. When? "When he strove with Aram-Naharaim." How so? When Joab went to make war with Aram-Naharaim, they came out to meet him and said to him: You are of the children of the sons of Jacob, and we are of the children of the sons of Laban, and behold, their pact [stands], as it is written, "This heap is a witness" (Genesis 31:52). When Joab heard this, he returned to David. He said to him: What do you say? Behold, their pact is the oath of Jacob our father. Immediately he seated the Sanhedrin, "Shushan Eduth, [to teach]." They taught him and said: In truth it was so, but they transgressed it first. Balaam the wicked, why did he transgress it? Did he not say so, "From Aram Balak brought me, the king of Moab" (Numbers 23:7)? And did not Cushan-Rishathaim enslave us, as it is said, "And the children of Israel served Cushan-Rishathaim eight years" (Judges 3:8)? They committed two wicked acts against us. When the court had instructed him, immediately he turned back against them and slew them, as it is said, "When he strove with Aram-Naharaim" (Psalms 60:2). Did he not make war with Aram? What is "And he smote Edom" (ibid.)? It should have said "Aram" and not "Edom"! Rather, when Joab came to make war with Aram, the children of Edom stood against him and said to him: Did not the Holy One, blessed be He, say to you, "Do not provoke them" (Deuteronomy 2:5)? Joab answered them: Did He not say to us, "You are passing through the territory of your brethren, the children of Esau" (ibid. 2:4)? Let us pass through, but they were unwilling. Joab said: If we destroy Edom now, on our return we will find neither food nor drink; rather, let us leave them be until we smite Aram, and then we will turn back upon them. Therefore it is said, "And Joab returned and smote Edom" (Psalms 60:2). The Holy One, blessed be He, said: You, destroy Edom little by little; when the time comes, I will consume and destroy it, as it is said, "And they shall possess the Negev, [the mountain of] Esau" (Obadiah 1:19). And it says, "And the exiles of this host" (ibid. 1:20). And it says, "And saviors shall go up on Mount Zion to judge the mountain of Esau" (ibid. 1:21). At that hour, "and the kingdom shall be the LORD's" (ibid.).
Joab, the Sanhedrin, and the War Against Aram and Edom
Midrash Tanchuma Buber, Devarim 3:1
ויאמר ה' אלי לאמר, רב לכם סוב את ההר הזה, ואת העם צו לאמר וגו' (דברים ב ב ג ד). זש"ה למנצח על שושן עדות מכתם לדוד ללמד (תהלים ס א), אימתי בהצותו את ארם נהרים ואת ארם צובה (שם שם ב), והלא כבר נאמר [ויך כל זכר באדום] כי (ששה) [ששת] חדשים ישב שם יואב וגו' (מ"א יא טז), ואחר כך אומר וישב יואב ויך את אדום בגיא מלח (תהלים ס ב), זש"ה קרוב מצדיקי מי יריב אתי נעמדה יחד וגו' (ישעיה נ ח), נתן הקב"ה תורה לישראל כדי שיזכו בה לכל האומות, אתה מוצא שיואב היה ראה סנהדרין, שנאמר (ואלה) [אלה] שמות הגבורים אשר לדוד יושב בשבת תחכמוני ראש [השלישי] (ש"ב כג ח), זה יואב, ודוד חכם מן הכל, שנאמר ואדוני חכם [כחכמת מלאך אלהים] (שם יד כ), ולא היו עושין דבר אלא על פי סנהדרין, שנאמר למנצח על שושן עדות מכתב לדוד (תהלים ס א), שושן עדות אלו סנהדרין, שנאמר סוגה בשושנים (שה"ש ז ג), עדות על שם התורה, שנקראת עדות, מכתם זה דוד, שעשה עצמו מך, ותם על שהלך בתמימות עם קונו, אימתי בהצותו את ארם נהרים, מהון כשהלך יואב להלחם עם ארם נהרים, יצאו לקראתו, אמרו לו אתה מבני בניו של יעקב, ואנו מבני בניו של לבן, והרי תנאי שלהם [קיים], דכתיב עד הגל הזה (בראשית לא נב), כששמע יואב חזר אצל דוד, א"ל מה אתה אומר הרי תנאו שבועת יעקב אבינו, מיד הושיבו סנהדרין שושן עדות, [ללמד] למדוהו ואמרו באמת כך היה, אלא הם עברוהו תחילה, בלעם הרשע מפני מה עבר, לא כך אמר מן ארם ינחני בלק מלך מואב וגו' (במדבר כג ז), וכושן רשעתים לא שיעבד בנו, שנאמר ויעבדו בני ישראל את כושן רשעתים שמונה שנים (שופטים ג ח), הם הרשיעו עלינו שתי רשעיות, כיון (שהודו),שהורו] לו ב"ד, מיד חזר עליהם והרגן, שנאמר בהצותו את ארם נהרים וגו' (תהלים ס ב), לא עם ארם עשה מלחמה, מהו ויך את אדום (שם), היה צריך לומר ארם, ולא אדום, אלא כשבא יואב להלחם עם ארם, עמדו עליו בני אדום, ואמרו לו לא אמר לכם הקב"ה אל תתגרו בם (דברים ב ד), השיבם יואב לא כך אמר לנו אתם עוברים בגבול אחיכם בני עשו (שם ב ג), הניחו אותנו לעבור ולא רצו, אמר יואב אם נחריב אדום עכשיו אין אנו מוצאים בחזירתנו לא אכילה ולא שתיה, אלא נניח אותם עד שנכה את ארם ונחזור עליהם, לכך נאמר וישב יואב ויך את אדום וגו' (תהלים ס ב), אמר הקב"ה אתם החריבו את אדום קימעא קימעא, כיון שיגיע זמן אני אכלה ואחריב אותה, שנאמר וירשו (את) הנגב (ואת ההר) [את הר] וגו' (עובדיה א יט), ואומר וגלות החל הזה וגו' (שם שם כ) ואומר ועלו מושיעים בהר ציון לשפוט את הר עשו (שם שם כא), באותה שעה והיתה לה' המלוכה (שם).