"And it came to pass, when Pharaoh let the people go" (Exodus 13:17). This is what Scripture says: "Wise of heart and mighty in strength—who has hardened himself against Him and remained whole?" (Job 9:4). "Wise of heart"—this is the Holy One, blessed be He, as it is said, "With Him are wisdom and might" (Job 12:13). "Who has hardened himself against Him and remained whole?"—the generation of the flood hardened themselves against Him, and He swept them away with water. The generation of the dispersion hardened themselves against Him, and He scattered them throughout all the world. The men of Sodom hardened themselves against Him; what was their end? "And the Lord rained down upon Sodom" (Genesis 19:24). Pharaoh said, "Who is the Lord?" (Exodus 5:2), and the Holy One, blessed be He, had said to him, "Let My people go" (Exodus 5:1); and he too hardened himself, as it is said, "And it came to pass, when Pharaoh hardened himself against letting us go" (Exodus 13:15). As soon as the plague of the firstborn came upon him, he immediately let them go. Therefore it is said, "And it came to pass, when Pharaoh let the people go" (Exodus 13:17).
Pharaoh Hardens Himself and Frees Israel After the Firstborn
Midrash Tanchuma Buber, Beshalach 1:1
ויהי בשלח פרעה וגו' (שמות יג יז). זש"ה חכם לבב ואמיץ כח מי הקשה אליו וישלם (איוב ט ד), [חכם לב], זה הקב"ה, שנאמר עמו חכמה (ותושיה) [וגבורה] וגו' (שם יב יג), מי הקשה אליו וישלם, דור המבול נתקשו כנגדו ושטפן במים, דור הפלגה נתקשו כנגדו, הפיצם בכל העלם, אנשי סדום נתקשו כנגדו, מה היה סופן, וה' המטיר על סדום (בראשית יט כד), פרעה אמר מי ה' (שמות ה' ב), והקב"ה אמר לו שלח את עמי (שם שם א), ואף הוא נתקשה, שנאמר ויהי כי הקשה פרעה (לשלחם) [לשלחנו] (שם יג טו), כיון שבאת מכת הבכורות עליו, מיד שלחן, לכך נאמר ויהי בשלח פרעה וגו'.