[Machine] Once, while we were traveling, darkness overtook us and the direction of the Qibla became unclear to us. Each of us prayed according to his own judgment. When it became clear, some of us had prayed in a direction other than the Qibla, while others had prayed towards the Qibla. We then mentioned this to the Messenger of Allah ﷺ , and he said, "Your prayers have passed and been accepted, for Allah says, 'And to Allah belongs the east and the west. So wherever you turn, there is the face of Allah.'" (Quran 2:115)
أُظْلِمَتْ مَرَّةً وَنَحْنُ فِي سَفَرٍ وَاشْتَبَهَتْ عَلَيْنَا الْقِبْلَةُ فَصَلَّى كُلُّ رَجُلٍ مِنَّا حِيَالَهُ فَلَمَّا انْجَلَتْ إِذَا بَعْضُنَا صَلَّى لِغَيْرِ الْقِبْلَةِ وَبَعْضُنَا قَدْ صَلَّى لِلْقِبْلَةِ فَذَكَرْنَا ذَلِكَ لِرَسُولِ اللهِ ﷺ فَقَالَ مَضَتْ صَلَاتُكُمْ وَنَزَلَتْ {فَأَيْنَمَا تُوَلُّوا فَثَمَّ وَجْهُ اللهِ} [البقرة 115]