The Messenger of Allah ﷺ led them in the prayer of fear. One row stood in front of him and another row stood behind him. He led those behind him in one cycle with two prostrations, then they advanced and took the place of their companions, while the others came forward and took the place of the first group. The Messenger of Allah ﷺ then led them in one cycle with two prostrations and gave the closing salutation. So the Prophet ﷺ performed two cycles, while each group performed one.
أن رسول الله ﷺ صلى بهم صلاة الخوف، فقام صف بين يديه، وصف خلفه، صلى بالذين خلفه ركعة وسجدتين، ثم تقدم هؤلاء حتى قاموا في مقام أصحابهم، وجاء أولئك فقاموا مقام هؤلاء، وصلى بهم رسول الله ﷺ ركعة وسجدتين، ثم سلم، فكانت للنبي ﷺ ركعتان، ولهم ركعة.
Nasai (1545) narrated it from Ibrahim bin Hasan, from Hajjaj bin Muhammad, from Shuba, from Hakam, from Yazid Faqir, from Jabir bin Abdullah, and he related it. Imam Ahmad (14180) also narrated it, and Ibn Khuzayma (1347) and Ibn Hibban (2869) graded it sahih, all of them narrating it from the hadith of Shuba in the same manner. Its chain is sahih.Nasai also narrated it through another route, from Abdul-Rahman bin Abdullah Masudi, who said, Yazid Faqir informed me, and in it, "Then the Prophet ﷺ said the closing salutation, and those behind him said the salutation, and those (others) said the salutation." He related this from Ahmad bin Miqdam, who said, Yazid bin Zuray narrated to us, who said, Abdul-Rahman bin Abdullah Masudi narrated to us with the same account, but in this abbreviated form.However, Ibn Khuzayma (1364) narrated it from Ahmad bin Miqdam Ajli, from Yazid bin Zuray, and Abu Dawud Tayalisi (1898) narrated it from Masudi at length and in detail. This is the wording of Abu Dawud, from Yazid bin Suhayb Faqir, who said, I asked Jabir bin Abdullah about the two rakats during travel, are they the shortened prayer? Jabir said, "The two rakats during travel are not the shortening. Rather the shortening is one rakat during combat."He said, then he began relating that he had been with the Messenger of Allah ﷺ during combat when the time for prayer came. The Messenger of Allah ﷺ stood, and one group lined up behind him while another group stood facing the enemy. He led the first group in one rakat and performed two prostrations with them. Then those who had prayed behind him went and took the position of the others, and those others came and lined up behind the Messenger of Allah ﷺ, and he led them in one rakat and performed two prostrations with them. Then the Messenger of Allah ﷺ sat, and said the closing salutation, and those behind him said the salutation, and those (others) said the salutation. So the Messenger of Allah ﷺ had prayed two rakats, while each group had prayed one rakat each.Then Yazid recited, "And when you are among them and lead them in prayer" [Nisa 4:102].Masudi's memory became confused later in life, but he is corroborated as mentioned above.