Another interpretation: "And it came to pass when Pharaoh let the people go" (Exodus 13:17). Yet elsewhere he says, "And moreover I will not let Israel go" (Exodus 5:2), and here he is letting them go. To what is the matter comparable? To a king who gave his servant money and said to him, "Buy me one fish." He went and bought him one stinking fish. The king said to him, "By your life, you shall not get out of one of three things: either you eat the fish, or you pay its price, or you are flogged with a hundred whips." He said to him, "I will eat it." He had not managed to eat a little of it before his soul loathed it. He said, "I will be flogged with a hundred whips." He had not managed to be flogged fifty whips before he was at the point of death. He said, "I will pay its price." It turned out that he ate a stinking fish, and was flogged, and paid its price. So too Pharaoh enslaved Israel in Egypt excessively. The Holy One, blessed be He, said to him, "Let My people go." He said, "I do not know the Lord" (Exodus 5:2). He brought ten plagues upon him, and he did not let them go. The Holy One, blessed be He, said to him, "By your life, you must give their wages," as it is said, "And the Lord gave the people favor <in the eyes of the Egyptians>" (Exodus 12:36). After he took the plagues and gave their wages, afterward he let them go. Therefore it is said, "And it came to pass when Pharaoh let the people go" (Exodus 13:17).
Pharaoh and the Stinking Fish Parable in Beshalach
Midrash Tanchuma Buber, Beshalach 8:1
ד"א ויהי בשלח פרעה, ולהלן הוא ואמר וגם את ישראל לא אשלח (שמות ה ב), וכאן הוא משלחן למה הדבר דומה, למלך שנתן לעבדו מעות, ואמר לו קח לי דג אחד, והלך ולקח לו דג אחד מבאיש, אמר לו המלך חייך אין אתה יוצא מאחת משלש, או הדג אתה אכול, או דמיו אתה נותן, או אתה לוקה מאה מגלבין, אמר לו אני אוכלו, לא הספיק לאכול ממנו קימעא עד שנקטה נפשו עליו, אמר אני לוקה מאה מגלבין, לא (הסכין לאכול) [הספיק ללקות] חמשים [מגלבין] עד שהסכין למות, אמר אני נותן את דמיו, נמצא אוכל דג מבאיש, ולוקה, ונותן את דמיו, כך פרעה שיעבד את ישראל במצרים יותר מדאי, אמר לו הקב"ה שלח עמי, אמר לא ידעתי את ה', הביא עליו עשר מכות ולא שלחן, א"ל הקב"ה חייך יש לך ליתן שכרן, שנאמר וה' נתן את חן העם וגו' (שמות יב לו), משנטל המכות ונתן שכרן, אחר כך שילחן, לכך נאמר ויהי בשלח פרעה.