The site of the Prophet's ﷺ mosque belonged to the tribe of Banu Najjar. On it stood date palms, ruined buildings, and graves from the days of pre-Islamic ignorance. The Messenger of Allah ﷺ said to them, "Name me a price for it."They replied, "We seek no price for it except from Allah ."So the Messenger of Allah ﷺ gave orders, and the date palms were cut down, the ruins cleared away, and the graves dug up. Before that, the Messenger of Allah ﷺ would pray in sheep pens wherever the time of prayer found him.
حدثنا يزيد أخبرنا حماد بن سلمة عن أبي التياح
كان موضع مسجد النبي ﷺ لبني النجار وكان فيه نخل وخرب وقبور من قبور الجاهلية فقال لهم رسول الله ﷺ ثامنوني فقالوا لا نبغي به ثمنا إلا عند الله عز وجل فأمر رسول الله ﷺ بالنخل فقطع وبالحرث فأفسد وبالقبور فنبشت وكان رسول الله ﷺ قبل ذلك يصلي في مرابض الغنم حيث أدركته الصلاة