Anas bin Malik reported,

When the Messenger of Allah ﷺ arrived, he stayed in the outskirts of Madinah among a clan called Banu Amr bin Awf, and remained with them for fourteen nights. Then he sent for the chiefs of Banu Najjar, and 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 around him, until he dismounted at the courtyard of Abu Ayub.He used to pray wherever the time of prayer found him, even praying in the sheep pens. Then he gave orders for the mosque to be built, and sent for the chiefs of Banu Najjar. When they came, he said, "Banu Najjar, name me a price for this garden of yours."They replied, "By Allah, we seek its price from no one but Allah عز وجل."Anas said, "In that land were graves of the polytheists, ruins, and date palms. The Messenger of Allah ﷺ ordered that the graves of the polytheists be dug up, the date palms cut down, and the ruins leveled. They lined up the trunks of the date palms as the qiblah of the mosque, and made its doorposts of stone. They began carrying the rocks while chanting verses, with the Messenger of Allah ﷺ alongside them, and they were saying, 'O Allah, there is no good except the good of the Hereafter, so grant victory to the Ansar and the Muhajirun.'"

Nasai 703

Sahih

أخبرنا عمران بن موسى قال حدثنا عبد الوارث عن أبي التياح

عن أنس بن مالك قال

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

النسائي 703صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Mosques
Chapter
Exhuming graves and taking their land as a masjid
Numbering
Darussalam 703
Nasai 703