Anas bin Malik reported,

The Messenger of Allah ﷺ arrived in Madinah and stayed in the upper part of the city among a tribe called Banu Amr bin Awf. He remained with them for fourteen nights, then he sent for the chiefs of Banu al-Najjar, who came wearing their swords.It is as if I can still see the Messenger of Allah ﷺ on his mount, with Abu Bakr riding behind him and the chiefs of Banu al-Najjar gathered around him, until he dismounted in the courtyard of Abu Ayub.The Messenger of Allah ﷺ used to pray wherever the time of prayer caught him, and he would pray in sheep pens. Then he gave orders for the mosque to be built. He sent for the chiefs of Banu al-Najjar, and when they came he said, "Banu al-Najjar, name me a price for this orchard of yours."They replied, "By Allah, no, we seek its price from none but Allah."Anas said, In it was what I am about to tell you. There were palm trees, graves of the polytheists, and ruins. The Messenger of Allah ﷺ ordered that the palm trees be cut down, the graves of the polytheists be dug up, and the ruins be leveled. So they lined up the felled palm trees in the direction of the qiblah and made the doorposts of stone.They began chanting work-songs while the Messenger of Allah ﷺ was with them, saying, "O Allah, there is no good except the good of the Hereafter, so grant victory to the Ansar and the Muhajirun."

Muslim 1173

Sahih

حدثنا يحيى بن يحيى وشيبان بن فروخ كلاهما عن عبد الوارث قال يحيى أخبرنا عبد الوارث بن سعيد عن أبي التياح الضبعي حدثنا

أنس بن مالك

أن رسول الله ﷺ قدم المدينة فنزل في علو المدينة في حي يقال لهم بنو عمرو بن عوف فأقام فيهم أربع عشرة ليلة ثم إنه أرسل إلى ملإ بني النجار فجاءوا متقلدين بسيوفهم قال فكأني أنظر إلى رسول الله ﷺ على راحلته وأبو بكر ردفه وملأ بني النجار حوله حتى ألقى بفناء أبي أيوب قال فكان رسول الله ﷺ يصلي حيث أدركته الصلاة ويصلي في مرابض الغنم ثم إنه أمر بالمسجد قال فأرسل إلى ملإ بني النجار فجاءوا فقال يا بني النجار ثامنوني بحائطكم هذا قالوا لا والله لا نطلب ثمنه إلا إلى الله قال أنس فكان فيه ما أقول كان فيه نخل وقبور المشركين وخرب فأمر رسول الله ﷺ بالنخل فقطع وبقبور المشركين فنبشت وبالخرب فسويت قال فصفوا النخل قبلة وجعلوا عضادتيه حجارة قال فكانوا يرتجزون ورسول الله ﷺ معهم وهم يقولون اللهم إنه لا خير إلا خير الآخره فانصر الأنصار والمهاجره

مسلم 1173صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Mosques and places of prayer
Chapter
Construction of the masjid of the Prophet ﷺ
Numbering
Darussalam 1173
Muslim 1173