It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) sent some people out for jihad, and I was among them. Because of bad weather it became difficult for us to identify the direction of the qiblah. Some people pointed toward the north and said that the qiblah was that way; they prayed in that direction and drew a line. Others said that the qiblah was toward the south; they too prayed in that direction and drew a line. When morning came and the sun rose, those lines were facing other than the qiblah. When we returned from the journey, we came to the Messenger of Allah (peace and blessings be upon him) and asked about this, and he (peace and blessings be upon him) remained silent. Then this verse was revealed: "To Allah belong the east and the west; wherever you turn, there is Allah" [Surah al-Baqarah: 115], meaning: wherever you are, in whichever direction.
We do not know of an authentic, strong chain for this hadith, because Asim bin Ubaydullah bin Umar al-Umari, Muhammad bin Ubaydullah al-Arzami and Muhammad bin Salim al-Kufi are all da'if (weak), and the route to Abd al-Malik al-Arzami is not clear, because it involves wijadah (transmission from a found written record) and other issues.
What is authentic is what is reported from Sayyiduna Abdullah bin Umar bin al-Khattab (may Allah be pleased with them both): that this verse was revealed specifically about voluntary prayer, that in voluntary prayer it is valid whichever way your mount is facing; and its mention has already passed.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2243