The Prophet ﷺ led the prayer of fear with one of the two groups, praying one rakah with them while the other group faced the enemy. Then they withdrew and took the position of the others, and the others came forward, and he prayed another rakah with them and gave the salam. Then this group stood and completed their remaining rakah, and the other group stood and completed their remaining rakah.
حدثنا محمد بن عبد الملك بن أبي الشوارب حدثنا يزيد بن زريع حدثنا معمر عن الزهري
أن النبي ﷺ صلى صلاة الخوف بإحدى الطائفتين ركعة والطائفة الأخرى مواجهة العدو ثم انصرفوا فقاموا في مقام أولئك وجاء أولئك فصلى بهم ركعة أخرى ثم سلم عليهم فقام هؤلاء فقضوا ركعتهم وقام هؤلاء فقضوا ركعتهم
Agreed upon. Bukhari recorded it in the Book of Military Expeditions, chapter on the Battle of Dhat al-Riqa, no. 4133, from the hadith of Yazid bin Zuray, and Muslim, no. 839, from the hadith of Muamar bin Rashid, from him.There are also narrations on this subject from Jabir [Muslim, no. 840, with several chains], Huzaifa [Abu Dawud, no. 1246], Zayd bin Thabit [Nasai, no. 1532, and Ibn Khuzayma graded it sahih, 2/294, no. 1345, and Ibn Hibban, no. 590], Ibn Abbas [Bukhari, no. 944, with several chains], Abu Hurairah [Abu Dawud, no. 1240], Ibn Masud [Abu Dawud, no. 1244, 1245], Sahl bin Abu Hathma [Bukhari, no. 4131, and Muslim, no. 841], Abu Ayyash Zurqi [Abu Dawud, no. 1236], and Abu Bakra [Abu Dawud, no. 1248].