Urwa bin Zubayr reported regarding the story of the Prophet's migration that the Messenger of Allah ﷺ stayed among the tribe of Amr bin Awf for over ten nights. He laid the foundation of the mosque that was founded upon piety, and the Messenger of Allah ﷺ prayed in it. Then he mounted his she-camel and set off, with the people walking alongside him, until she knelt down at the site of the Messenger of Allah's mosque in Medina.
أخبرني عروة بن الزبير في قصة هجرته… فلبث رسول الله ﷺ في بني عمرو بن عوف بضع عشرة ليلة. وأسس المسجد الذي أسس على التقوى، وصلى فيه الرسول الله ﷺ، ركب احلته، فسار يمشي معه الناس، حتى بركت عند مسجد رسول الله بالمدينة…
Bukhari narrated it in the Virtues of the Ansar (3906) from Yahya bin Bukayr, who said, Layth told us, from Aqeel, Ibn Shihab said, and then he mentioned it.Al-Hafiz said, its form is mursal, but Hakim also connected it (3/11) through the route of Mamar, from Zuhri, who said, Urwa informed me that he heard Zubayr narrate it. He also said, the masjid that was founded on piety is the masjid of Quba, he said, it is the first masjid built in Madinah, and in reality it is the first masjid in which the Prophet ﷺ prayed with his companions in a congregation openly, and the first masjid built for the Muslim community in general.He said, the majority hold that what is meant by it is the masjid of Quba, and this is what appears evident from the verse. Then he said, the truth is that each of the two was founded on piety, and the words of Allah Almighty, "... in it are men who love to purify themselves" [Tawbah 9:108] support the view that what is meant is the masjid of Quba. And with Abu Dawud, by a sahih chain, from Abu Hurairah, from the Prophet ﷺ, he said, it was revealed, "... in it are men who love to purify themselves," concerning the people of Quba.Based on this, the wisdom in his answer that the masjid founded on piety was his own masjid was to remove the misconception that this was specific to the masjid of Quba. Al-Dawudi and others said, this is not a contradiction, because each of the two was founded on piety, and Suhayli said the same.Others added that the words of Allah Almighty, "from the first day" [Tawbah 9:108] indicate that it is the masjid of Quba, because its founding took place on the first day the Prophet ﷺ settled in the abode of the "Hijrah." See, Fath al-Bari (7/245).