Mention Maryam in the Book, how she withdrew from her people to an eastern place, and veiled herself from them. Then We sent Our Spirit to her and it took on for her the form of a well-made man. She said, "I seek refuge from you with the All-Merciful if you have fear for Allah." He said, "I am only your Lord's messenger so that He can give you a pure boy." (Surah Maryam: 16-19)
As we are informed in the verses above, after the completion of one of the stages of her training, Maryam withdrew from her people to an eastern place and spent some part of her life there. Right at this phase of her life, Jibril (Gabriel) appeared before Maryam by the command of Allah. Maryam, being a noble and chaste woman, was deeply disturbed on seeing a stranger. Yet, Jibril explained that he was an angel sent by Allah to give her glad tidings of a son:
When the angels said, "Maryam, your Lord gives you good news of a Word from Him. His name is the Messiah, ‘Isa, son of Maryam of high esteem in the world and the hereafter, and one of those brought near." (Surah Al ‘Imran: 45)
Upon these glad tidings, Maryam raised the question of how she could have a son when no man had ever touched her:
She said, "How can I have a boy when no one has touched me and I am not an unchaste woman?" He said, "It will be so! Your Lord says, ‘That is easy for Me. It is so that We can make him a Sign for mankind and a mercy from Us.’ It is a matter already decreed." So she conceived him and withdrew with him to a distant place. (Surah Maryam: 20-22)
She said, "My Lord! How can I have a son when no one has ever touched me?" He said, "It will be so." Allah creates whatever He wills. When He decides on something, He just says to it, ‘Be!’ and it is." (Surah Al ‘Imran: 47)
During the time Maryam remained in the "distant place" mentioned in the above verses, Allah supported her both physically and materially. She was totally under His protection and care during her pregnancy. All her needs were especially met by Allah. Meanwhile, by making her settle in a secluded place, Allah prevented all the harm that people devoid of understanding of this situation were likely to bring her.