Rabbi Judah says: when the angels came to Abraham, he ran to bring a calf, and the calf ran to the Cave of Machpelah, and he entered after it and saw Adam and Eve lying on their beds, with candles kindled over them and a sweet fragrance like a pleasing aroma. Therefore he desired it for a burial holding. He spoke to the people of Jebus to purchase it from them for a sale of gold and an eternal deed. Now were they Jebusites? Were they not Hittites? Rather they were called after the name of the city. They would not accept this from him; they said: we know that the Holy One, blessed be He, will in the future give all these lands to your seed - make a covenant with us that your seed will not inherit the city of the Jebusites. And he made a covenant with them, and afterward purchased the Cave of Machpelah from them. What did the men of Jebus do? They made copper images and inscribed upon them the covenant of the oath, and set them up in the city square. When Israel came to the Land, they wished to enter the city but could not, because of the covenant, as it says, "and the Jebusites dwelling in Jerusalem" (Joshua 15:63). And King David wished to enter and they would not permit him, as it says, "and they said to David, saying, You shall not come here" (2 Samuel 5:6). David saw that oath and turned back, as it says, "and David dwelt in the stronghold and called it the City of David" (2 Samuel 5:9). They said: we will not let you enter until you remove these images upon which Abraham's oath is written, as it says, "unless you remove the blind and the lame" - and as it says, "the blind and the lame shall not come into the house" (2 Samuel 5:8); heaven forbid that blind and lame people came to the Temple - rather these were the images, as it says, "they have eyes but they do not see" (Psalms 115:5), "hated by David's soul," for David hated idolaters. David said: whoever ascends first and removes these images shall be chief; and Joab son of Zeruiah went up and became chief. And afterward he purchased the city of the Jebusite in an eternal sale, as it says, "and David gave to Ornan" (1 Chronicles 21:25).
Abraham's Oath the Idols of Jebus and David's Conquest
Yalkut Shimoni on Nach 28:1
רבי יהודה אומר כשבאו המלאכים לאברהם רץ להביא בן בקר ורץ בן בקר למערת המכפלה ונכנס אחריו וראה אדם וחוה שוכבים על מטותיהם ונרות דולקים עליהם וריח טוב כריח ניחוח לפיכך חמדה לאחוזת קבר. אמר לבני יבוס לקנות מהם בממכר זהב ובמכתב עולם, וכי יבוסים היו והלא חתיים היו אלא על שם העיר נקראו, ולא קבלו עליהם, אמרו יודעים אנו שעתיד הקב"ה ליתן לזרעך את כל הארצות האלה כרות עמנו ברית שאין זרעך יורש מעיר יבוסי וכרת עמהם ברית ואחר כך קנה מהם מערת המכפלה. מה עשו אנשי יבוס עשו צלמי נחשת וכתבו עליהם ברית השבועה והעמידו אותם ברחוב העיר וכשבאו ישראל לארץ רצו ליכנס לעיר ולא היו יכולים מפני הברית שנאמר ואת היבוסי יושב ירושלים וגו', והמלך דוד רצה ליכנס ולא הניחוהו שנאמר (ויאמרו אנשי יבוס) [ויאמר לדוד לאמר] לא תבא הנה. אותה שבועה ראה דוד וחזר לאחוריו שנאמר וישב דוד במצודה ויקרא לה עיר דוד. אמרו אין אנו מניחין אותך ליכנס עד שתסיר את הצלמים הללו שכתוב עליהם שבועת אברהם שנאמר כי אם הסירך העורים והפסחים, וכמו שנאמר עור ופסח לא יבא (בית ה') [אל הבית] חס ושלום עורים ופסחים באו למקדש אלא אלו הצלמים שנאמר עינים להם ולא יראו, שנואי נפש דוד שהיה דוד שונא עוברדי ע"ז. אמר דוד כל מי שיעלה בראשונה (יד) ויסיר את הצלמים הללו יהיה לראש ועלה יואב בן צרויה והיה ראש. ואח"כ קנה את עיר היבוסי בממכר עולם שנאמר ויתן דוד לארנן וגו':