حَدَّثَنَا مُسَدَّدٌ، حَدَّثَنَا يَحْيَى، حَدَّثَنَا مُحَمَّدُ بْنُ عَجْلاَنَ، حَدَّثَنِي سَعِيدٌ الْمَقْبُرِيُّ، عَنْ أَبِي هُرَيْرَةَ، قَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم إِذَا سَافَرَ قَالَ ‏"‏ اللَّهُمَّ أَنْتَ الصَّاحِبُ فِي السَّفَرِ وَالْخَلِيفَةُ فِي الأَهْلِ اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنْ وَعْثَاءِ السَّفَرِ وَكَآبَةِ الْمُنْقَلَبِ وَسُوءِ الْمَنْظَرِ فِي الأَهْلِ وَالْمَالِ اللَّهُمَّ اطْوِ لَنَا الأَرْضَ وَهَوِّنْ عَلَيْنَا السَّفَرَ ‏"‏ ‏.‏
Translation
Narrated Abdullah ibn Umar

When the Messenger of Allah (ﷺ) sat on his camel to go out on a journey, he said: "Allah is Most Great" three times. Then he said: "Glory be to Him Who has made subservient to us, for we had not the strength for it, and to our Lord do we return. O Allah, we ask Thee in this journey of ours, uprightness, piety and such deeds as are pleasing to Thee. O Allah, make easy for us this journey of ours and make its length short for us. O Allah, Thou art the Companion in the journey, and the One Who looks after the family and property in our absence." When he returned, he said these words adding: "Returning, repentant, serving and praising our Lord." The Prophet (ﷺ) and his armies said: "Allah is Most Great" when they went up to high ground; and when armies said: "Allah is most Great" when they went up to high ground; and when they descended, they said: "Glory be to Allah." So the prayer was patterned on that.