The Catechism in Questions & Answers

127. How did God protect the Child Jesus?

Through a dream, God told Joseph, Mary’s husband, to flee to Egypt with her and the Child (cf. Matthew 2: 13- 14). After King Herod died, they moved back to Nazareth in Galilee.