عَنِ ابْنِ عَبَّاسٍ قَالَ: لَمَّا دَخَلَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ الْبَيْتَ دَعَا فِي نَوَاحِيهِ كُلِّهَا وَلَمْ يُصَلِّ حَتَّى خَرَجَ مِنْهُ فَلَمَّا خَرَجَ رَكَعَ رَكْعَتَيْنِ فِي قُبُلِ الْكَعْبَةِ وَقَالَ: «هَذِه الْقبْلَة» . رَوَاهُ البُخَارِيّ وَرَوَاهُ مُسْلِمٌ عَنْهُ عَنْ أُسَامَةَ بْنِ زَيْدٍ
Translation

Ibn ‘Umar said that the Prophet used to go to the mosque in Quba'* every Saturday, walking and riding, and he would pray two rak'as in it. * The village outside Medina where the Prophet stayed a few days before entering Medina at the time of the Hijra. Before leaving he laid the foundations of a mosque there. Al-Qur’an; 9:108 is said to refer to this mosque. In the preceding verse reference is made to another mosque which had been built in a spirit of opposition.(Bukhari and Muslim.)