It is reported from the Prophet ﷺ that he led the prayer of fear, performing two rakahs with the group behind him and another two rakahs with the group that came afterward. So the Prophet ﷺ prayed four rakahs in total, while each of the two groups prayed only two rakahs.
أخبرنا عمرو بن علي قال حدثنا يحيى بن سعيد قال حدثنا الأشعث عن الحسن
عن النبي ﷺ أنه صلى صلاة الخوف بالذين خلفه ركعتين والذين جاءوا بعد ركعتين فكانت للنبي ﷺ أربع ركعات ولهؤلاء ركعتين ركعتين
[sahih] Previously mentioned, no. 837 and 1552, and it is in Al-Kubra, no. 1943.