Sunan Ibn Majah, Book 4, Hadith 8 (In-Book)

It was narrated that Anas bin Malik said: "The location where the Prophet's Mosque was built belonged to Banu Najjar. In it there were date-palm trees and graves of the idolaters. The Prophet said to them: 'Name its price.' They said: 'We will never take any money for it.' The Prophet built it and they were assisting him, and the Prophet was saying: 'The real life is the life of the Hereafter so forgive the Ansar and the Muhajirah.' Before the mosque was built, the Prophet would perform prayer wherever he was when the time for prayer came."

حَدَّثَنَا عَلِيُّ بْنُ مُحَمَّدٍ، حَدَّثَنَا وَكِيعٌ، عَنْ حَمَّادِ بْنِ سَلَمَةَ، عَنْ أَبِي التَّيَّاحِ الضُّبَعِيِّ، عَنْ أَنَسِ بْنِ مَالِكٍ، قَالَ كَانَ مَوْضِعُ مَسْجِدِ النَّبِيِّ ـ صلى الله عليه وسلم ـ لِبَنِي النَّجَّارِ وَكَانَ فِيهِ نَخْلٌ وَمَقَابِرُ لِلْمُشْرِكِينَ فَقَالَ لَهُمُ النَّبِيُّ ـ صلى الله عليه وسلم ـ ‏"‏ ثَامِنُونِي بِهِ ‏"‏ ‏.‏ قَالُوا لاَ نَأْخُذُ لَهُ ثَمَنًا أَبَدًا ‏.‏ قَالَ فَكَانَ النَّبِيُّ ـ صلى الله عليه وسلم ـ يَبْنِيهِ وَهُمْ يُنَاوِلُونَهُ وَالنَّبِيُّ ـ صلى الله عليه وسلم ـ يَقُولُ ‏"‏ أَلاَ إِنَّ الْعَيْشَ عَيْشُ الآخِرَةِ فَاغْفِرْ لِلأَنْصَارِ وَالْمُهَاجِرَةِ ‏"‏ ‏.‏ قَالَ وَكَانَ النَّبِيُّ ـ صلى الله عليه وسلم ـ يُصَلِّي قَبْلَ أَنْ يَبْنِيَ الْمَسْجِدَ حَيْثُ أَدْرَكَتْهُ الصَّلاَةُ ‏.‏

sunnah.com