The Gospel of Matthew narrates that Joseph, warned in a dream that Herod intended to search for and kill the infant Jesus, took Mary and the child and fled by night to Egypt, remaining there until Herod's death, at which point a further dream instructed Joseph to return, though he settled the family in Nazareth in Galilee rather than in Judea, out of continued fear of Herod's son and successor Archelaus, who had inherited rule over that region.
Matthew presents the episode as fulfilling a line from the prophet Hosea, "out of Egypt I called my son," a citation that in its original context in Hosea refers not to an individual but collectively to Israel's exodus from Egypt under Moses, a use of prophecy Matthew adapts to apply typologically to Jesus rather than quoting it in its original historical sense.
The Flight into Egypt is not independently dated within the narrative and has no fixed liturgical commemoration of its own in most Western calendars, though it is depicted extensively in Christian art and has particular devotional significance within the Coptic Christian tradition of Egypt itself, which maintains a body of local tradition, not found in the biblical text, identifying specific sites the holy family is said to have visited during their stay.