Sayyiduna Abu Hurayrah (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) led the people in the fear prayer and divided them into two groups. One group was behind the Prophet (peace and blessings be upon him) and the other group facing the enemy. He (peace and blessings be upon him) led those behind him in one rak'ah and had them make two prostrations in it. Then he (peace and blessings be upon him) stood up, and they also stood up with him (peace and blessings be upon him). When he (peace and blessings be upon him) had stood upright, those who were behind him (peace and blessings be upon him) walked backwards. They stood behind those who were facing the enemy. Then the other group came. They stood behind the Prophet (peace and blessings be upon him). They prayed one rak'ah of their own while the Messenger of Allah (peace and blessings be upon him) was standing. Then they stood up. The Prophet (peace and blessings be upon him) led them in the other rak'ah, so they and the Messenger of Allah (peace and blessings be upon him) each had two rak'ahs. Then those who were facing the enemy came. They prayed one rak'ah of their own with two prostrations. Then they sat behind the Prophet (peace and blessings be upon him). Then he (peace and blessings be upon him) gave the salam with all of them.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب صلاة الخوف / 6057