Joseph, who had been warned in a dream to leave Bethlehem, quickly got up and took the child and his mother to Egypt that night. They stayed in Egypt until the death of Herod the Great.
This happened in order to fulfill the word spoken by the Lord through his prophets, saying,
“Out of Egypt did I call my son.”
When Herod realized that he had been mocked by the wise men, he went into a rage and sent his soldiers out to kill all the male children in Bethlehem and the surrounding area who were two years old or younger.
The wicked act of Herod the Great fulfilled the prophecy that was spoken through Jeremiah, who said,
“A voice was heard in Ramah. Weeping and great mourning, Rachel weeping for her children. And she would not be comforted because they are no more.”