The Messenger of Allah ﷺ performed the fear prayer at Dhu Qarad. One row stood behind him while another row faced the enemy. He prayed one rakah with them, then gave the salam. So the Prophet ﷺ had prayed two rakahs, while each group had prayed one rakah.
حدثنا عبد الرحمن حدثنا سفيان عن أبي بكر يعني ابن أبي الجهم عن عبيد الله بن عبد الله
صلى رسول الله ﷺ صلاة الخوف بذي قرد صفا خلفه وصفا موازي العدو وصلى بهم ركعة ثم سلم فكانت للنبي ﷺ ركعتين ولكل طائفة ركعة