The Messenger of Allah ﷺ performed the prayer of fear on one of his expeditions. One group stood with him while another faced the enemy. He prayed one rakah with those who were with him, then they departed and the others came, and he prayed one rakah with them. Each of the two groups then made up one rakah on their own.Ibn Umar said, "If the fear is greater than that, then pray while riding or standing, gesturing with movements."
صلى رسول الله ﷺ صلاة الخوف في بعض أيامه، فقامت طائفة معه، وطائفة بإزاء العدو، فصلى بالذين معه ركعة، ثم ذهبوا، وجاء الآخرون فصلى بهم ركعة، ثم قضت الطائفتان ركعة ركعة. قال ابن عمر: فإذا كان خوف أكثر من ذلك فصل راكبا أو قائما، تومي إيماء.
Bukhari narrated it in the Book of Fear (943), and Muslim in the Book of Prayer of the Traveler (306/830), both from the hadith of Musa bin Uqba, from Nafi, from Ibn Umar, and he mentioned it. The wording is Muslim's, and Bukhari abridged it and made Ibn Umar's statement, "If they are more numerous than that, let them pray standing and riding," attributed to the Prophet ﷺ. Al-Hafiz favored attributing it to the Prophet after thoroughly examining all the routes of Ibn Umar's hadith.Malik narrated it in the Book of the Prayer of Fear (3), from Nafi, that Abdullah bin Umar, when asked about the prayer of fear, would say, the imam and a group of people advance, and the imam leads them in one rakat, while another group remains between him and the enemy without having prayed. When those with him have prayed one rakat, they fall back to the position of those who have not yet prayed, without ending their prayer. Then those who had not prayed advance and pray one rakat with him. Then the imam concludes his prayer, having prayed two rakats. Each of the two groups then stands and prays one rakat for themselves after the imam has finished, so that each group will have prayed two rakats. But if the fear is more severe than that, they pray as men standing on their feet, or riding, whether facing the qibla or not facing it.Malik said, Nafi said, I do not think that Abdullah bin Umar narrated this except from the Messenger of Allah ﷺ.Bukhari narrated it in the Book of Tafsir (4535) through the route of Malik, with the same wording.As for what Simak Hanafi narrated from Ibn Umar, from the Prophet ﷺ, "He led one group in one rakat and the other group in another rakat, during the prayer of fear," without mentioning that they made up another rakat, Bayhaqi said, "We have narrated from Salim and Nafi, from Ibn Umar, that each of the two groups made up their missing rakat, and the ruling goes to the affirming report in such a case." End of quote, Sunan al-Kubra (3/263).