Another matter, “it was at midnight” – that is what is written: “At midnight I will rise to give thanks to You because of the ordinances [mishpetei] of Your righteousness” (Psalms 119:62). At midnight I will rise to give thanks to You for the judgments [mishpatim] that You performed in Egypt, and the righteousness that You performed for us. How so? Since Moses said: “I will smite all firstborn” (Exodus 12:12), there were some [Egyptians] who were afraid and some who were not afraid.
One who was afraid would take his firstborn to an Israelite and would say to him: ‘Take this one and let him stay the night with you.’ When midnight arrived, the Holy One blessed be He killed all the firstborn. For those who were located in the houses of the Israelites, the Holy One blessed be He would step between the Israelite and the Egyptian and would take the soul of the Egyptian and leave the soul of the Israelite.
The Jew would awaken and find the Egyptian dead between each and every one [of his sons], as it is stated: “I will pass over you, and there will be no plague upon you” (Exodus 12:13). The Israelites began saying: “At midnight I will rise to give thanks to You.” That is why it is stated: “Because of the ordinances of Your righteousness.”