عَنِ ابْنِ عَبَّاسٍ قَالَ: لَمَّا دَخَلَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ الْبَيْتَ دَعَا فِي نَوَاحِيهِ كُلِّهَا وَلَمْ يُصَلِّ حَتَّى خَرَجَ مِنْهُ فَلَمَّا خَرَجَ رَكَعَ رَكْعَتَيْنِ فِي قُبُلِ الْكَعْبَةِ وَقَالَ: «هَذِه الْقبْلَة» . رَوَاهُ البُخَارِيّ
وَرَوَاهُ مُسْلِمٌ عَنْهُ عَنْ أُسَامَةَ بْنِ زَيْدٍ
Translation
Abu Usaid reported God's Messenger as saying
When any of you enters the mosque he should say, “O God, open to me the gates of Thy mercy, “and when he goes out he should say “O God, I ask Thee out of Thine abundance.” Muslim transmitted it.