The Prophet ﷺ turned aside toward the mountain pass only to relieve himself.
حدثنا يونس حدثنا فليح عن نافع
إنما عدل النبي ﷺ إلى الشعب لحاجته
No references are available.
Its isnad is sahih. I have not found it in this abbreviated wording elsewhere. Bukhari (3:415) narrated, from the hadith of Juwayriya from Nafi, who said, Abdullah bin Umar used to combine Maghrib and Isha at Jam, except that he would pass by the ravine that the Messenger of Allah ﷺ had taken, entering it, relieving himself, and performing wudu, and he would not pray until he prayed at Jam. His statement "yantafid" is with fa and dad, meaning he would clean himself with stones. This agrees with the wording here, "for his need."Bukhari also narrated (3:415), as did Muslim (1:364), via the route of Musa bin Uqba from Kurayb, the freedman of Ibn Abbas, from Usama bin Zayd, that when the Prophet ﷺ departed from Arafah he turned toward the ravine, relieved himself, and performed wudu. I said, "Messenger of Allah, will you pray?" He said, "The prayer is ahead of you."This ravine is close to Muzdalifa, as is clear from the context of the narrations.