Anas bin Malik reported,

The site of the Messenger of Allah's ﷺ mosque belonged to the tribe of Banu Najjar. It contained cultivated land, palm trees, and graves of polytheists. He said, "Banu Najjar, name me a price for it."They replied, "We seek no price for it except from Allah."So the palm trees were cut down, the cultivated land was leveled, and the graves of the polytheists were dug up.Before the mosque was built, the Prophet of Allah ﷺ would pray wherever the time of prayer overtook him, including in the resting places of sheep.While they were carrying the stones to build the mosque, the Prophet ﷺ would say, "Allah, the true good is the good of the Hereafter, so forgive the Ansar and the Muhajirun."

Ahmad 13561

Sahih

حدثنا عفان حدثنا حماد بن سلمة عن أبي التياح

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

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

أحمد 13561صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Anas bin Malik
Numbering
Darussalam 13561
Ahmad 13561