Language:
كتاب المغازى
64  
Military Expeditions led by the Prophet (pbuh) (Al-Maghaazi)
(31)
Chapter: The Ghazwa of Dhat-ur-Riqa
(31)
باب غَزْوَةُ ذَاتِ الرِّقَاعِ
Sahih al-Bukhari 4133

Narrated `Abdullah bin `Umar:

Allah's Messenger (ﷺ) led the Fear-prayer with one of the two batches of the army while the other (batch) faced the enemy. Then the first batch went away and took places of their companions (i.e. second batch) and the second batch came and he led his second rak`a with them. Then he (i.e. the Prophet: finished his prayer with Taslim and then each of the two batches got up and completed their remaining one rak`a.

حَدَّثَنَا مُسَدَّدٌ، حَدَّثَنَا يَزِيدُ بْنُ زُرَيْعٍ، حَدَّثَنَا مَعْمَرٌ، عَنِ الزُّهْرِيِّ، عَنْ سَالِمِ بْنِ عَبْدِ اللَّهِ بْنِ عُمَرَ، عَنْ أَبِيهِ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم صَلَّى بِإِحْدَى الطَّائِفَتَيْنِ، وَالطَّائِفَةُ الأُخْرَى مُوَاجِهَةُ الْعَدُوِّ، ثُمَّ انْصَرَفُوا، فَقَامُوا فِي مَقَامِ أَصْحَابِهِمْ، فَجَاءَ أُولَئِكَ فَصَلَّى بِهِمْ رَكْعَةً، ثُمَّ سَلَّمَ عَلَيْهِمْ، ثُمَّ قَامَ هَؤُلاَءِ فَقَضَوْا رَكْعَتَهُمْ، وَقَامَ هَؤُلاَءِ فَقَضَوْا رَكْعَتَهُمْ‏.‏
Reference : Sahih al-Bukhari 4133
In-book reference : Book 64, Hadith 177
USC-MSA web (English) reference : Vol. 5, Book 59, Hadith 456
  (deprecated numbering scheme)