It has been built, by Prophet Mohammedr, in first year of Hijra after he built Qiba' Mosque. Prophet Mohammedr, stayed few days in Qiba' then went to Medina on Friday once he arrived built his holy Mosque where his Camel was laying. Prophet Mohammed peace be upon him bought the land and used palm trunks as support for the roof which was made of beaten clay and palm leaves.
The holy mosque had three doors: Bab Rahmah to the south, Bab Jibril to the west and Bab al-Nisa' to the east. Gate of Mercy (Bab Rahmah) is where our Beloved, Prophet Mohammed r used to enter his holy mosque. Prophet's Mosque is the second holiest mosque in the world after al-Haram in Mecca.
The holy mosque gone through nine expansions by time passing. First expansion by Caliph Abu Bakrt, Second by Caliph Umar Ibn Khattabt, third by Caliph Uthman Ibn Affan t, fourth by the Umayyad Caliph Al Walid Ibn Abd Al-Malik, fifth by the Abbasid Caliphal Mahdi and last ones are the Saudi ones. The holy mosque now has 41 doors and 10 minarets. Abu Hurayrah narrated that the Prophet Muhamad peace and blessings of Allah be upon him said: “The area between my house and my minbar is one of the gardens ( riyaad, sing. rawdah) of Paradise, and my minbar is on my cistern (hawd)” Bukhaari, 1196; Muslim, 1391.