(1) باب ابْتِنَاءِ مَسْجِدِ النَّبِيِّ صلى الله عليه وسلم
Anas b. Malik reported:
The Messenger of Allah (ﷺ) came to Medina and stayed in the upper part of Medina for fourteen nights with a tribe called Banu 'Amr b 'Auf. He then sent for the chiefs of Banu al-Najir, and they came with swords around their inecks. He (the narrator) said: I perceive as if I am seeing the Messenger of Allah (ﷺ) on his ride with Abu Bakr behind him and the chiefs of Banu al-Najjar around him till he alighted in the courtyard of Abu Ayyub. He (the narrator) said: The Messenger of Allah (ﷺ) said prayer when the time came for prayer, and he prayed in the fold of goats and sheep. He then ordered mosques to be built and sent for the chiefs of Banu al-Najjar, and they came (to him). He (the Holy Prophet) said to them: O Banu al-Najjar, sell these lands of yours to me. They said: No, by Allah. we would not demand their price, but (reward) from the Lord. Anas said: There (in these lands) were trees and graves of the polytheists, and ruins. The Messenger of Allah (may peace he upon him) ordered that the trees should be cut, and the graves should be dug out, and the ruins should be levelled. The trees (were thus) placed in rows towards the qibla and the stones were set on both sides of the door, and (while building the mosque) they (the Companions) sang rajaz verses along with the Messenger of Allah (ﷺ): O Allah: there is no good but the good of the next world, So help the Ansar and the Muhajirin.
Reference: Sahih Muslim 524 a
In-book reference: Book 5, Hadith 13
USC-MSA web (English) reference(deprecated numbering scheme): Book 4, Hadith 1068