Abu Dawud Book 2, Hadith Number 1236.

Chapter : A fouth view that goes that al the people should utter the first takbir together though their back is towards the qiblah. then a sectiom of them should offer one rakah along with the imam and go to the place of their companions facing the enemy and the other section should come and offer one rakah by themselves. the imam then should lead them in one rakah. thereafter the section which stands before the enemy should come forward and offer one rakah by themselves while the imam should remain seated. when they complete one rakah he should utter the salutation along with all of them.

Narated By Abu Hurairah : Urwah ibn az-Zubayr reported that Marwan ibn al-Hakam asked Abu Hurairah: Did you pray in time of danger with the Apostle of Allah (PBUH)?

Abu Hurairah replied: Yes. Marwan then asked: When? Abu Hurairah said: On the occasion of the Battle of Najd. The Apostle of Allah (PBUH) stood up to offer the afternoon prayer. One section stood with him (to pray) and the other was standing before the enemy, and their backs were towards the qiblah. The Apostle of Allah (PBUH) uttered the takbir and all of them too uttered the takbir, i.e. those who were with him and those who were facing the enemy. Then the Apostle of Allah (PBUH) offered one rak’ah and the section that was with him also prayed one rak’ah. He then prostrated himself and those who were with him also prostrated, while the other section was standing before the enemy.

The Apostle of Allah (PBUH) then stood up and the section with him also stood up. They went and faced the enemy and the section that was previously facing the enemy stepped forward. They bowed and prostrated while the Apostle of Allah (PBUH) was standing in the same position. Then they stood up and the Apostle of Allah (may peace be upon) prayed another rak’ah and all of them bowed and prostrated along with him. After that the section that was standing before the enemy came forward and they bowed and prostrated, while the Apostle of Allah (PBUH) remained seated and also those who were with him. The salutation then followed. The Apostle of Allah (PBUH) uttered the salutation and all of them uttered it together. The Apostle of Allah (PBUH) prayed two rak’ahs and each of the two sections prayed one rak’ah with him (and the other by themselves).