Shemot / Exodus 9:27 · Drash
וַיִּשְׁלַח פַּרְעֹה וַיִּקְרָא לְמֹשֶׁה וּלְאַהֲרֹן וַיֹּאמֶר אֲלֵהֶם חָטָאתִי הַפָּעַם יְהוָה הַצַּדִּיק וַאֲנִי וְעַמִּי הָרְשָׁעִים׃
And Pharaoh sent and called for Moshe and for Aharon and said to them: "I have sinned this time. The Eternal is righteous, and I and my people are in the wrong.
Drash דְּרָשׁ
The same mouth
At their first meeting Pharaoh said: "Who is the Eternal? I do not know the Eternal." The midrash sets our verse beside those words and sees how each of Pharaoh's words came back to him.
Midrash Tanchuma (Buber): the Holy One, blessed is He, said to Pharaoh: you said "who (מִי)," and by the waters (מֵי) of the sea you will be punished, in the sea you will know who I am. You said "I do not know the Eternal," and tomorrow you will say "the Eternal is righteous." You said "I will not let them go," and tomorrow you yourself will send off each one. Rashi: because the Egyptians said "the Eternal is righteous," they merited burial.
How Midrash Tanchuma (Buber) and Rashi explain it
Midrash Tanchuma (Buber) The Eternal is righteous
Another explanation: "Who is the Eternal" (Shemot / Exodus 5:2). The Holy One, blessed is He, said to him: you said "who (מִי)." By your life, by "waters" (מֵי) you will be punished: "who" reversed is the waters of the sea. In the sea you will know who I am. You said "I do not know the Eternal" (ibid.). By your life, tomorrow you will say: "The Eternal is righteous, and I and my people are in the wrong" (9:27). You said "and Israel too I will not let go" (5:2). By your life, tomorrow you will take each one by the hand to send him off. That is why it says: "And it was, when Pharaoh let the people go" (13:17).
Rashi "The earth swallowed them" (Shemot / Exodus 15:12)
From here we learn that the Egyptians merited burial as a reward for saying "the Eternal is righteous" (above, 9:27).
Takeaway
The midrash plays on a word: Pharaoh's "who" (מִי) sounds like the "waters" (מֵי) of the sea, where he will learn who the Eternal is.
The Song at the Sea says: "You stretched out Your right hand, the earth swallowed them" (Shemot / Exodus 15:12). Rashi reads "the earth swallowed them" as burial.
In the story of the going out of Egypt, "And it was, when Pharaoh let the people go" (Shemot / Exodus 13:17) opens the portion Beshalach. The very words Pharaoh denied became words about him.