8. The Prophet’s Guidance for Prayer During Fear60
* If the enemy was in the direction of the Qiblah, he (Peace be upon him) arranged the worshipers in two rows behind him. He (Peace be upon him) said "Allahu akbar" and they repeated after him. Then they all made ruku` and rose up from it together. For prostration, the front row behind him prostrated while the back row remained standing facing the enemy. When the Prophet stood up for the second rak`ah the back row would make two prostrations, get up and advance to take the place of the first row, which would move back to take their place.

In this way, both groups would have the benefit of the first row, and the back row could make the prostrations of the second rak`ah with him. In the second rak`ah, the two rows acted in the same manner as in the first. When the Prophet (Peace be upon him) sat for tashahhud the new back row would make the two prostrations and then join him in the tashahhud and final salutation.
60 Zadul-Ma`ad (1/510)

* If the enemy was not in the direction of Qiblah, he (Peace be upon him) sometimes arranged them in two groups: one facing the enemy and the other praying with him. The group praying with him would perform one rak`ah before moving to the place of the second group, which would simultaneously shift to perform the second rak`ah with him. Once he finished the prayer, the members of each group would complete the remaining rak`ah of the prayer on their own.

* Sometimes he (Peace be upon him) performed one rak`ah with one of the two groups and while standing for the second rak`ah this first group would conclude the second rak`ah and go to face the enemy. The other group would then join him and he (Peace be upon him) would lead them while performing his second rak`ah. He (Peace be upon him) would again wait for them to complete the other rak`ah before leading them in the final salutation.
* On other occasions, he (Peace be upon him) would perform two rak`ahs with one group and complete the prayer with them. Then he (Peace be upon him) would do the same with the second group.

* And sometimes he (Peace be upon him) would pray one rak`ah with one group and they would leave without completing the second rak`ah. Then he would do the same with the other group. Thus, he (Peace be upon him) performed two rak`ahs while both groups performed one rak`ah each.