How long was Maryam pregnant with ‘Eesa (peace be upon him)?
Question

Was the virgin Maryam pregnant with ‘Eesa (peace be upon him) for nine months? Or when the angels came to her and told her to take refuge at the trunk of the palm tree, did she give birth to him at that point?
Praise be to Allah.The scholars differed as to how long Maryam was pregnant with ‘Eesa (peace be upon him). 
The view of the majority is that it was nine months, as with all other humans. 
‘Ikrimah said: Eight months, and said: For that reason no child born at eight months’ gestation lives, so as to preserve the uniqueness of ‘Eesa. 
It was narrated that Ibn ‘Abbaas said: No sooner did she become pregnant but she gave birth. 
Ibn Katheer said (3/117) concerning this report narrated from Ibn ‘Abbaas: 
This is strange, and appears to have been taken from the apparent meaning of the verses in which Allaah says (interpretation of the meaning): 
“So she conceived him, and she withdrew with him to a far place (i.e. Bethlehem valley about 4-6 miles from Jerusalem).
And the pains of childbirth drove her to the trunk of a date palm”
[Maryam 19:22] 
The particle fa (translated here as ‘and’), in Arabic, implies a succession of events, but things follow one another at their own pace, as in the verse where Allaah says (interpretation of the meaning): 
“And indeed We created man (Adam) out of an extract of clay (water and earth).
Thereafter We made him (the offspring of Adam) as a Nutfah (mixed drops of the male and female sexual discharge and lodged it) in a safe lodging (womb of the woman).
Then We made the Nutfah into a clot (a piece of thick coagulated blood), then We made the clot into a little lump of flesh, then We made out of that little lump of flesh bones”
[al-Muminoon 23:12-14] 
Here the particle fa (translated as ‘then’) indicates succession at the appropriate pace. 
And it is proven in al-Saheehayn (al-Bukhari and Muslim) that between each two stages is a period of forty days [i.e., it remains a nutfah for forty days, then a clot for forty days, then a lump of flesh for forty days].  
And Allaah says (interpretation of the meaning): 
“See you not that Allaah sends down water (rain) from the sky, and then the earth becomes green?”
[al-Hajj 22:63] 
The well-known view is the apparent meaning– and Allaah is able to do all things – which is that she bore him as all other women bear their children. Hence when the signs of pregnancy appeared on her, and there was with her in the mosque a righteous man from among her relatives who worshipped in the temple with her, who was called Yoosuf al-Najjaar.  When he saw that her belly had become swollen he found it strange. Then he decided to think well of her because of what he knew of her innocence, honour, religious commitment and worship. Then he thought about her situation, and he could not stop thinking about this matter. So he said, speaking indirectly: “O Maryam, I am going to ask you about something, so do not get alarmed.” She said, “What is it?” He said: “Has any tree or plant ever grown without a seed? Has any child ever been born without a father?” She said: “Yes, I understood what you are referring to. As for your asking whether any tree or plant has ever grown without a seed, when Allaah first created trees and plants He created them without seeds. And has any child ever been born without a father? Allaah created Adam without either a father or a mother.” So he believed her and left her alone. 
When Maryam felt that her people were accusing her, she withdrew to a far place, i.e. far away from them, so that she would not see them and they would not see her. 
Muhammad ibn Ishaaq said: When she became pregnant with him and her menses ceased, and she experienced the discomforts that all pregnant women face, then no household experienced what the household of Zakariyah experienced. Talk spread among the Children of Israel and they said that the one who was responsible for this was her companion Yoosuf because there was no one else in the church with her except him. So she stayed away from people and put a screen between her and them so that no one could see her and she could not see anyone. 
End quote from Ibn Katheer.
And Allaah knows best.