The Messenger of Allah ﷺ prayed one rakah with one of the two groups while the other group faced the enemy. Then they withdrew and took the position of their companions, and the others came forward and he prayed one rakah with them. He then gave the salam, after which the first group stood and completed their remaining rakah, and the second group stood and completed their remaining rakah.
حدثنا مسدد حدثنا يزيد بن زريع حدثنا معمر عن الزهري
أن رسول الله ﷺ صلى بإحدى الطائفتين والطائفة الأخرى مواجهة العدو ثم انصرفوا فقاموا في مقام أصحابهم أولئك فجاء أولئك فصلى بهم ركعة ثم سلم عليهم ثم قام هؤلاء فقضوا ركعتهم وقام هؤلاء فقضوا ركعتهم