The Messenger of Allah used to come to the Quba mosque, sometimes riding and sometimes walking, and he would pray two rak'ahs there.
كان رسول الله يأتي مسجد قباء راكبا وماشيا، فيصلي فيه ركعتين.
Muslim narrated it in the book of Hajj (1399/516) from Muhammad bin Abdullah Ibn Numayr, who said, our father narrated to us, from Ubaydullah, from Nafi, from Ibn Umar, and he mentioned the same. Bukhari narrated it in the book on the merit of prayer in the masjid of Makkah and Madinah (1194) through Yahya (bin Saeed Qattan) from Ubaydullah with the same wording, except that he did not mention "two rakahs." Bukhari said, "Ibn Numayr added, Ubaydullah narrated to us, from Nafi, that he would pray two rakahs in it," and this is connected through Muslim's route.Bukhari also narrated it (1191) through Ayub, from Nafi, from Ibn Umar, that he would not pray the Duha prayer except on two days, the day he arrived in Makkah, for he would arrive there in the forenoon and circle the House, then pray two rakahs behind the Station, and the day he came to Masjid Quba, for he would come to it every Saturday, and when he entered the masjid he disliked to leave it until he had prayed in it. He used to relate that the Messenger of Allah ﷺ used to visit it, riding and on foot.