Her husband Joseph, being a righteous man and unwilling to expose her to public disgrace, planned to dismiss her quietly.
But just when he had resolved to do this, an angel of the Lord appeared to him in a dream and said, "Joseph, son of David, do not be afraid to take Mary as your wife, for the child conceived in her is from the Holy Spirit.
She will bear a son, and you are to name him Jesus, for he will save his people from their sins."
All this took place to fulfill what had been spoken by the Lord through the prophet:
"Look, the virgin shall conceive and bear a son, and they shall name him Emmanuel," which means, "God is with us."
When Joseph awoke from sleep, he did as the angel of the Lord commanded him; he took her as his wife,
but had no marital relations with her until she had borne a son; and he named him Jesus.
References for Matthew 1:25