Anas bin Malik reported,

When the Messenger of Allah ﷺ arrived in Medina, he stayed in the upper part of the city among a clan called Banu Amr bin Awf. He remained with them for fourteen nights, then sent for the chiefs of Banu Najjar.They came wearing their swords. It is as though I can still see the Messenger of Allah ﷺ on his mount, with Abu Bakr riding behind him and the chiefs of Banu Najjar gathered around him, until he dismounted in the courtyard of Abu Ayub. He used to pray wherever the time of prayer overtook him, and he would pray in the folds where sheep were kept.Then he ordered that the mosque be built. He sent for the chiefs of Banu Najjar, and when they came he said, "Banu Najjar, name me a price for this orchard of yours."They replied, "No, by Allah, we will not seek payment for it except from Allah."In that orchard, as I am telling you, were graves of polytheists, ruins, and date palms. The Messenger of Allah ﷺ ordered that the graves of the polytheists be dug up, the ruins leveled, and the palms cut down. They lined up the palm trunks as the qiblah of the mosque and made its doorposts of stone.They began carrying those stones while chanting in rhythm, with the Messenger of Allah ﷺ alongside them, saying, "O Allah, there is no good except the good of the hereafter, so grant victory to the Ansar and the Muhajirun."

Bukhari 3932

Sahih

حدثنا مسدد حدثنا عبد الوارث ح و حدثنا إسحاق بن منصور أخبرنا عبد الصمد قال سمعت أبي يحدث حدثنا أبو التياح يزيد بن حميد الضبعي قال حدثني

أنس بن مالك رضي الله عنه قال

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

البخاري 3932صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Virtues of the Ansar
Chapter
Prophet's ﷺ and his companions' arrival in Madinah
Numbering
Darussalam 3932
Bukhari 3932