It was narrated that Anas bin Malik said:
When the Messenger of Allah (ﷺ) came to Al-Madinah, he alighted in the upper part of Al-Madinah among the tribe called Banu 'Amr bin 'Awf and he stayed with them for fourteen nights. Then he sent for the chiefs of Banu An-Najjar, and they came with their swords by their sides. It is as if I can see the Messenger of Allah (ﷺ) on his she-camel with Abu Bakr riding behind him (on the same camel) and the chiefs of Banu An-Najjar around him, until he dismounted in the courtyard of Abu Ayyub. The Prophet (ﷺ) used to offer the prayer wherever he was when the time for prayer came, and he would pray even in sheepfolds. Then he ordered that the Masjid be built. He sent for the chiefs of Banu An-Najjar, and when they came, he said: 'O Banu An-Najjar, name me a price for this grove of yours.' They said: 'By Allah, we will not ask for its price except from Allah.' Anas said: In (that grove) there were graves of idolators, ruins and date-palm trees. The Messenger of Allah (ﷺ) ordered that the graves of the idolators be dug up, the ruins be leveled and the date-palm trees be cut down. The trunks of the trees were arranged so as to form the walls facing the Qiblah. The stone pillars were built at the sides of its gate. They started to move the stones, reciting some lines of verse, and the Messenger of Allah (ﷺ) was with them when they were saying: 'O Allah! There is no good except the good of the Hereafter. So bestow victory on the Ansar and the Muhajirin.'