The Prophet ﷺ led the fear prayer at noon. One group lined up behind him while the other faced the enemy. He prayed two rakahs with the first group and then gave the closing salam. Those who had prayed with him went off and took the position of their companions, then the second group came and prayed behind him. He prayed two rakahs with them and then gave the closing salam. So the Messenger of Allah ﷺ performed four rakahs, while each group of his companions performed only two. This is the ruling Hasan used to give.
حدثنا عبيد الله بن معاذ حدثنا أبي حدثنا الأشعث عن الحسن
صلى النبي ﷺ في خوف الظهر فصف بعضهم خلفه وبعضهم بإزاء العدو فصلى بهم ركعتين ثم سلم فانطلق الذين صلوا معه فوقفوا موقف أصحابهم ثم جاء أولئك فصلوا خلفه فصلى بهم ركعتين ثم سلم فكانت لرسول الله ﷺ أربعا ولأصحابه ركعتين ركعتين وبذلك كان يفتي الحسن
ﷺ. Grading, its chain of transmission is daif. Nasai narrated it in the Book of Leadership in Prayer, chapter on the difference in intention between the imam and the one following him, hadith no. 837, from the hadith of Ashath, through this route. Hasan Basri narrated it using "an" without specifying direct hearing, and the hadith of Yahya bin Abu Kathir was narrated by Muslim, hadith no. 843, which suffices in its place.