Masjid-e-Nabwi is the masjid (mosque) established by the Prophet (peace and blessings of Allah be on him) upon his migration to Madinah. It is the second most revered masjid in Islam and the second largest in the world, after Masjid al-Haram in Makkah.
When the Prophet (peace and blessings of Allah be on him) migrated to Madinah (then called Yathrib), the chiefs of the city and his immediate followers rode around his camel in their best clothes and in glittering armour. Everyone was hoping he would stop by their house. The Prophet (peace and blessings of Allah be on him) would answer everyone politely and kindly, “[This camel] is commanded by Allah; wherever it stops, that will be my home.” The camel moved on with slackened reins, reaching the site of the present masjid and knelt down. The Prophet (peace and blessings of Allah be on him) alighted and said, “This is the home” and inquired as to who owned the land. The land contained a few date trees, graves of polytheists, a resting spot for herds of cattle and was owned by two orphan brothers, Sahl and Suhail. The Prophet (peace and blessings of Allah be on him) purchased the land, had the trees cleared and the polytheists graves dug up and levelled.
He then gave orders that his newly acquired courtyard should be made into a masjid (mosque) and work began immediately. Most of the building was done by bricks made of stones and kneaded clay but in the middle of the northern wall (which faced the original Qibla in Jerusalem) stones were put on either side of the prayer niche. The palms in the courtyard were cut down and their trunks were used as pillars to support the roof of palm branches, but the greater part of the courtyard was left open. Small stones were laid on the floor to prevent it from becoming too muddy. At the rear of the masjid, the Prophet (peace and blessings of Allah be on him) built a shaded area called as-Suffah in which the poor companions would spend the night. Two small huts were also constructed on the eastern side of the masjid to accommodate his two wives at the time, Aisha and Sauda (may Allah be pleased with them).
The Prophet (peace and blessings of Allah be on him) gave the Muslims of Madinah the title of Ansar which means Helpers, whereas the Muslims of Quraysh and other tribes who had left their homes and emigrated to the oasis he called Muhajirun, meaning Emigrants. All took part in the work, including the Prophet (peace and blessings of Allah be on him) himself, and as they worked they chanted two verses which one of them had made up for the occasion:“O Allah, no good is but the good Hereafter, So help the Helpers and the Emigrants.” And sometimes they chanted: “No life there is but the life of the Hereafter. Mercy, O Allah, on Emigrants and Helpers.”
The masjid was built twice during the lifetime of the Prophet (peace and blessings of Allah be on him). The first time was shortly after he had made the Hijra to Madinah in 622 CE, with the size of the masjid being approximately 35 x 30 meters and the height 2.5 meters. It was rebuilt seven years later after the Fath (opening) of Khaibar. The increasing number of Muslims by then necessitated an increase in the area of the mosque to accommodate more worshippers. Usman (may Allah be pleased with him) paid for the land to accommodate the extension which made the masjid approximately 50 x 50 meters. The height was also increased to 3.5 meters.
When the revelation came down to change the Qibla to Makkah in 624 CE, the whole masjid was re-orientated to the south.
The masjid also served as a religious school, community center, court and also as a confinement for prisoners.
Anas (may Allah be pleased with him) reports that the Prophet (peace and blessings of Allah be on him) said:“Whoever performs forty salat in my masjid, not missing one salat in the masjid, for him is granted exemption from the fire of Hell, and exemption from punishment and he shall remain free of hypocrisy.” [Ahmad]
Abu Umar (may Allah be pleased with him) narrated that the Prophet (peace and blessings of Allah be on him) said:“One salat offered in my masjid is superior to one thousand salats offered in other masjids except Masjid al-Haraam (Makkah al-Mukarramah).” [Bukhari]
References: History of Madinah Munawwarah – Dr. Muhammad Ilyas Abdul Ghani, Wikipedia, History of Madina – Ali Hafiz, Encyclopedia of Islam – Al-Arabee Ben Razzouq, Virtues of Hajj – Sheikh Muhammad Zakariyya Kandhalvi.