"And Melchizedek king of Salem" (Genesis 14:18). This was Shem son of Noah, who was king in Jerusalem, as it is said, "And in Salem was His tabernacle" (Psalms 76:3). "He brought out bread and wine." In every place where there is wine, it left a mark. And what mark did it make here? That he lost the priesthood, as it is said, "after the order of Melchizedek" (Psalms 110:4). And on what account? Because he put the blessing of Abraham before the blessing of the Holy One, blessed be He. And Shem also asked of the Holy One, blessed be He, that He give the priesthood to Abraham our father, because he foresaw by the Holy Spirit that no seed fit for the priesthood would issue from him, while Abraham our father was fit and a master of Torah and worthy of the priesthood. And so the Holy One, blessed be He, did, and gave him the priesthood. And Shem accepted it upon himself and immediately gave him the tithe, as it is said, "and he gave him a tithe of all" (verse 20) — as it is said of Abraham, "and he was priest of God Most High," for thus his father blessed him, "and let him dwell in the tents of Shem" (Genesis 9:27). And why did Melchizedek go to Abraham when he returned from the war? So that Abraham would know that there was in the heart of Melchizedek no hatred at all toward Abraham over his having killed Elam, for Elam was the son of Shem, as it is said, "the sons of Shem: Elam etc." (Genesis 10:22). "And Tidal king of Goyim." There was one city in the Land of Israel and its name was Goyim, as it is said, "the king of Goyim one" (Joshua 12:23).
Melchizedek Is Shem and Why He Lost the Priesthood to Abraham
Midrash Aggadah, Genesis 14:18
ומלכי צדק מלך שלם. זה היה שם בן נח שהיה מלך בירושלם, שנאמר ויהי בשלם סוכו (תהלים עו ג): הוציא לחם ויין. כל מקום שיש בו יין עשה רושם, ומה רושם עשה כאן, שאיבד את הכהונה, שנאמר על דברתי מלכי צדק (תהלים קי ד), ומפני מה על שהקדים ברכת אברהם לברכת הקב"ה, ואף שם ביקש מן הקב"ה שיתן הכהונה לאברהם אבינו, לפי שצפה ברוח הקודש שלא יצא ממנו זרע הגון לכהונה, ואברהם אבינו היה הגון ובעל תורה והיה ראוי לכהונה, וכן עשה הקב"ה ונתן לו הכהונה, ושם קיבל עליו ונתן לו לאלתר המעשר, שנאמר ויתן לו מעשר מכל (פסוק כ), שנאמר לאברהם והוא כהן לאל עליון, שכן בירכו אביו וישכן באהלי שם (בראשית ט כז), ולמה הלך מלכי צדק אצל אברהם כשחזר מן המלחמה, כדי שידע אברהם שאין בלב מלכי צדק על אברהם שום איבה על שהרג את עילם, שעילם היה בן שם, שנאמר (ובני) [בני] שם עילם וגו' (בראשית י כב): ותדעל מלך גוים. עיר אחת היתה בארץ ישראל ושמה גוים, שנאמר מלך גוים אחד: