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 prayed one rakah with two prostrations with those behind him, then this group moved forward until they stood in the place of their companions, and the others came forward until they stood in the place of this group. The Messenger of Allah ﷺ then prayed one rakah with two prostrations with them and gave the closing salutation. So the Prophet ﷺ performed two rakahs, while each group performed only one.
حدثنا محمد بن جعفر حدثنا شعبة عن الحكم عن يزيد الفقير
أن رسول الله ﷺ صلى بهم صلاة الخوف فقام صف بين يديه وصف خلفه فصلى بالذي خلفه ركعة وسجدتين ثم تقدم هؤلاء حتى قاموا في مقام أصحابهم وجاء أولئك حتى قاموا مقام هؤلاء فصلى بهم رسول الله ﷺ ركعة وسجدتين ثم سلم فكانت للنبي ﷺ ركعتين ولهم ركعة
Its isnad is sahih. Hakam is Ibn Utayba, the trustworthy, firmly reliable jurist, and Yazid Faqir is Ibn Suhayb.The hadith was narrated by Abu Dawud, 1244, in the chapter on prayer, from those who said that he prays one rakat with each group. Haythami graded it sahih in 2/197, by way of Tabarani.