From the Gospel of Matthew:
Now the birth of Jesus Christ took place in this way. When his mother Mary had been betrothed to Joseph, before they came together she was found to be with child from the Holy Spirit. And her husband Joseph, being a just man and unwilling to put her to shame, resolved to divorce her quietly. But as he considered these things, behold, an angel of the Lord appeared to him in a dream, saying, “Joseph, son of David, do not fear to take Mary as your wife, for that which is conceived in her is from the Holy Spirit. She will bear a son, and you shall call his name Jesus, for he will save his people from their sins.”
All this took place to fulfill what the Lord had spoken by the prophet:
“Behold, the virgin shall conceive and bear a son,
and they shall call his name Immanuel”
(which means, God with us). When Joseph woke from sleep, he did as the angel of the Lord commanded him: he took his wife, but knew her not until she had given birth to a son. And he called his name Jesus.
Now after Jesus was born in Bethlehem of Judea in the days of Herod the king, behold, wise men from the east came to Jerusalem, saying, “Where is he who has been born king of the Jews? For we saw his star when it rose and have come to worship him.” When Herod the king heard this, he was troubled, and all Jerusalem with him; and assembling all the chief priests and scribes of the people, he inquired of them where the Christ was to be born. They told him, “In Bethlehem of Judea, for so it is written by the prophet:
“‘And you, O Bethlehem, in the land of Judah,
are by no means least among the rulers of Judah;
for from you shall come a ruler
who will shepherd my people Israel.’”
Then Herod summoned the wise men secretly and ascertained from them what time the star had appeared. And he sent them to Bethlehem, saying, “Go and search diligently for the child, and when you have found him, bring me word, that I too may come and worship him.” After listening to the king, they went on their way. And behold, the star that they had seen when it rose went before them until it came to rest over the place where the child was. When they saw the star, they rejoiced exceedingly with great joy. And going into the house they saw the child with Mary his mother, and they fell down and worshiped him. Then, opening their treasures, they offered him gifts, gold and frankincense and myrrh. And being warned in a dream not to return to Herod, they departed to their own country by another way.
Now when they had departed, behold, an angel of the Lord appeared to Joseph in a dream and said, “Rise, take the child and his mother, and flee to Egypt, and remain there until I tell you, for Herod is about to search for the child, to destroy him.” And he rose and took the child and his mother by night and departed to Egypt and remained there until the death of Herod. This was to fulfill what the Lord had spoken by the prophet, “Out of Egypt I called my son.”
Then Herod, when he saw that he had been tricked by the wise men, became furious, and he sent and killed all the male children in Bethlehem and in all that region who were two years old or under, according to the time that he had ascertained from the wise men. Then was fulfilled what was spoken by the prophet Jeremiah:
“A voice was heard in Ramah,
weeping and loud lamentation,
Rachel weeping for her children;
she refused to be comforted, because they are no more.”
But when Herod died, behold, an angel of the Lord appeared in a dream to Joseph in Egypt, saying, “Rise, take the child and his mother and go to the land of Israel, for those who sought the child’s life are dead.” And he rose and took the child and his mother and went to the land of Israel. But when he heard that Archelaus was reigning over Judea in place of his father Herod, he was afraid to go there, and being warned in a dream he withdrew to the district of Galilee. And he went and lived in a city called Nazareth, so that what was spoken by the prophets might be fulfilled, that he would be called a Nazarene.
(Matthew 1.18–2.23 ESV)