Mary, the mother of Jesus, was betrothed to Joseph, but was found to be pregnant through the Holy Spirit. Joseph intended to divorce her quietly, but an angel told him in a dream that he should take Mary as his wife and name the child Jesus, because he would save his people from their sins. Joseph awoke and did all that the angel commanded.
Chapter 1 of Matthew’s Gospel recounts Jesus’s birth and naming and the beginning of chapter 2 reveals that Jesus was born in Bethlehem during the time of Herod the Great. Magi from the east came to Herod and asked him where they would find the King of the Jews, because they had seen his star. Advised by the chief priests and teachers, Herod sent the Magi to Bethlehem, where they worshiped the child and gave him gifts. When they had departed, an angel appeared to Joseph in a dream and warned him to take the child and his mother and flee to Egypt, for Herod intended to kill him. The Holy Family remained in Egypt until Herod died, when Joseph took them to Nazareth in Galilee for fear of Herod’s son who now ruled in Jerusalem.