"And he was priest to God Most High" (Genesis 14:18). Rabbi Abba bar Kahana said: every mention of wine in the Torah leaves a mark [of harm], except this one. Rabbi Levi said: even from this one we did not escape unharmed, for from there [this episode] He decreed upon him, "and they shall enslave them and afflict them" (Genesis 15:13). "And Melchizedek king of Shalem," who was born circumcised, and so forth (as written above on the verse "And God created the human in His image," at reference 16). (Genesis 14:19-20) The Holy One, blessed be He, wished to bring forth the priesthood from Shem, as it is said, "and he was priest to God Most High." But since he put the blessing of Abraham before the blessing of the Omnipresent, He brought it forth from Abraham instead, as it is said, "And he blessed him and said, Blessed be Abram..." (Genesis 14:19). Abraham said to him, "Does one put the blessing of the servant before the blessing of his master?" Immediately He gave it to Abraham, as it is said, "The LORD said to my lord... You are a priest forever after the manner of Melchizedek" (Psalms 110:1, 4). And this is what is written, "And he was priest to God Most High": he is a priest, but his offspring are not priests.
The Priesthood Is Taken from Shem and Given to Abraham
Yalkut Shimoni on Torah 74:2
וְהוּא כֹהֵן לְאֵל עֶלְיוֹן. רַבִּי אַבָּא בַּר כַּהֲנָא אָמַר, כָּל יַיִן שֶׁכָּתוּב בַּתּוֹרָה עוֹשֶׂה רֹשֶׁם חוּץ מִזֶּה רַבִּי לֵוִי אָמַר, אַף לֹא יָצָאנוּ מִיָּדוֹ שֶׁמִּשָּׁם קָרָא עָלָיו (בראשית טו, יג) "וַעֲבָדוּם וְעִנּוּ אוֹתָם". וּמַלְכִּי צֶדֶק מֶלֶךְ שָׁלֵם שֶׁנּוֹלַד מָהוּל וְכוּ' (כְּדִכְתִיב לְעֵיל בַּפָּסוּק וַיִּבְרָא אֱלֹהִים אֶת הָאָדָם בְּצַלְמוֹ) (בְּרֶמֶז מ"ז) [ט"ז]. (בראשית יד יט-כ) בִּקֵּשׁ הַקָּדוֹשׁ בָּרוּךְ הוּא לְהוֹצִיא כְּהוּנָה מִשֵּׁם שֶׁנֶּאֱמַר, וְהוּא כֹהֵן לְאֵל עֶלְיוֹן, כֵּיוָן שֶׁהִקְדִּים בִּרְכַּת אַבְרָהָם לְבִרְכַּת הַמָּקוֹם הוֹצִיאוֹ מֵאַבְרָהָם שֶׁנֶּאֱמַר, וַיְבָרְכֵהוּ וַיֹּאמַר בָּרוּךְ אַבְרָם וְגוֹ' אָמַר לוֹ אַבְרָהָם, וְכִי מַקְדִּימִין בִּרְכַּת עֶבֶד לְבִרְכַּת רַבּוֹ, מִיָּד נְתָנָהּ לְאַבְרָהָם, שֶׁנֶּאֱמַר, (תהלים קי, א ד) "נְאֻם ה' לַאֲדוֹנִי וְגוֹ' עַל דִּבְרָתִי מַלְכִּי צֶדֶק" וְהַיְינוּ דִּכְתִיב, וְהוּא כֹהֵן לְאֵל עֶלְיוֹן, הוּא כֹּהֵן וְאֵין זַרְעוֹ כֹּהֵן.