Hazrat Urwah bin Zubair (may Allah have mercy on him) narrates from Mardan bin Hakam that he asked Sayyiduna Abu Hurairah (may Allah be pleased with him), "Did you offer the prayer of fear (Salat al-Khawf) with the Noble Prophet (peace and blessings be upon him)?" Sayyiduna Abu Hurairah (may Allah be pleased with him) replied, "Yes." He asked, "When?" He replied, "In the year of the Battle of Najd." The Messenger of Allah (peace and blessings be upon him) stood for the Asr prayer and one group stood with him, while the other group stood facing the enemy, their backs towards the Qiblah. The Messenger of Allah (peace and blessings be upon him) said « اللهُأَكْبَرُ », so all the people said « اللهُأَكْبَرُ » and began the prayer, both those who stood with him and those who were facing the enemy. Then the Messenger of Allah (peace and blessings be upon him) prayed one rak'ah and the group with him also performed one rak'ah. Then the Messenger of Allah (peace and blessings be upon him) and his group performed the prostrations, while the other group remained arrayed before the enemy. Then the Messenger of Allah (peace and blessings be upon him) and his close row stood up. So they went to face the enemy. And the group that was arrayed before the enemy came forward, so they performed the bowing (ruku') and (two) prostrations, while during this time the Messenger of Allah (peace and blessings be upon him) remained standing. Then they stood up, so the Messenger of Allah (peace and blessings be upon him) prayed the second rak'ah, so they also performed the bowing and prostrations with him. Then the group that was standing before the enemy came forward, so they (by themselves) performed the second bowing and prostrations, while during this time the Messenger of Allah (peace and blessings be upon him) and his companions (the first group) remained seated. Then the Messenger of Allah (peace and blessings be upon him) said the salam, and the Messenger of Allah (peace and blessings be upon him) and all the people said the salam together. In this way, the Messenger of Allah (peace and blessings be upon him) completed two rak'ahs, and each person from both groups also completed two rak'ahs.
If the enemy is behind the qiblah and the imam waits standing after finishing the first rak‘ah for the group that made takbir not facing the qiblah, then they pray the rak‘ah which the imam preceded them with, and the first group waits sitting after finishing two rak‘ahs before the salam, so that the second rak‘ah may be completed, in order to unite them all with the salam, and they give salam when their imam gives salam.
Hadith Referenceصحيح ابن خزيمه / جماع أبواب صلاة الخوف / 1361
If the enemy is behind the qiblah and the imam waits standing after finishing the first rak‘ah for the group that made takbir not facing the qiblah, then they pray the rak‘ah which the imam preceded them with, and the first group waits sitting after finishing two rak‘ahs before the salam, so that the second rak‘ah may be completed, in order to unite them all with the salam, and they give salam when their imam gives salam.
Hazrat Urwah bin Zubair (may Allah have mercy on him) narrates from Mardan bin Hakam that he asked Sayyiduna Abu Hurairah (may Allah be pleased with him), "Did you offer the prayer of fear (Salat al-Khawf) with the Noble Prophet (peace and blessings be upon him)?" Sayyiduna Abu Hurairah (may Allah be pleased with him) replied, "Yes." He asked, "When?" He replied, "In the year of the Battle of Najd." The Messenger of Allah (peace and blessings be upon him) stood for the Asr prayer and one group stood with him, while the other group stood facing the enemy, their backs towards the Qiblah. The Messenger of Allah (peace and blessings be upon him) said « اللهُأَكْبَرُ », so all the people said « اللهُأَكْبَرُ » and began the prayer, both those who stood with him and those who were facing the enemy. Then the Messenger of Allah (peace and blessings be upon him) prayed one rak'ah and the group with him also performed one rak'ah. Then the Messenger of Allah (peace and blessings be upon him) and his group performed the prostrations, while the other group remained arrayed before the enemy. Then the Messenger of Allah (peace and blessings be upon him) and his close row stood up. So they went to face the enemy. And the group that was arrayed before the enemy came forward, so they performed the bowing (ruku') and (two) prostrations, while during this time the Messenger of Allah (peace and blessings be upon him) remained standing. Then they stood up, so the Messenger of Allah (peace and blessings be upon him) prayed the second rak'ah, so they also performed the bowing and prostrations with him. Then the group that was standing before the enemy came forward, so they (by themselves) performed the second bowing and prostrations, while during this time the Messenger of Allah (peace and blessings be upon him) and his companions (the first group) remained seated. Then the Messenger of Allah (peace and blessings be upon him) said the salam, and the Messenger of Allah (peace and blessings be upon him) and all the people said the salam together. In this way, the Messenger of Allah (peace and blessings be upon him) completed two rak'ahs, and each person from both groups also completed two rak'ahs.
Hadith Referenceصحيح ابن خزيمه / جماع أبواب صلاة الخوف / 1361
Hazrat Urwah bin Zubair narrates that I heard Sayyiduna Abu Hurairah (may Allah be pleased with him) while Furwan bin Hakam was asking him about the prayer of fear. So Sayyiduna Abu Hurairah (may Allah be pleased with him) said, I was present with the Messenger of Allah (peace and blessings of Allah be upon him) in that battle. He says that the Messenger of Allah (peace and blessings of Allah be upon him) divided the people into two groups, then narrated similar to the aforementioned hadith, and in the second rak'ah he stated that the group which had prayed with the Prophet (peace and blessings of Allah be upon him) took up their weapons, then they walked backwards until they stood near the enemy. And at the end of the hadith, these words were added: the people stood up in such a state that all of them had participated in the prayer with the Messenger of Allah (peace and blessings of Allah be upon him).
Hadith Referenceصحيح ابن خزيمه / جماع أبواب صلاة الخوف / 1362