The Messenger of Allah ﷺ led one section in one rak'ah of prayer and the other section was facing the enemy. Then they turned away and took the position of the other section. They (the other section) came and he (the Prophet) led them in the second rak'ah. He then uttered the salutation. Thereafter they stood up and completed the remaining rak'ah, they went away and the other section completed their remaining rak'ah. Abu Dawud said: This tradition has been narrated by Nafi' and Khalid b. Ma'dan from Ibn 'Umar in like manner from the Prophet ﷺ. This has also been transmitted similarly by Masruq ad Yusuf b. Mihran on the authority of Ibn 'Abbas. This has been narrated by Yunus from al-Hasan from Abu Musa something similarly, saying that Abu Musa has done so. (Using translation from Abū Dāʾūd 1243)
أَنَّ رَسُولَ اللهِ ﷺ صَلَّى صَلَاةَ الْخَوْفِ بِإِحْدَى الطَّائِفَتَيْنِ رَكْعَةً وَالطَّائِفَةُ الْأُخْرَى مُوَاجِهَةٌ الْعَدُوَّ ثُمَّ انْصَرَفُوا فَقَامُوا فِي مَقَامِ أُولَئِكَ وَجَاءَ أُولَئِكَ فَصَلَّى بِهِمْ رَكْعَةً أُخْرَى ثُمَّ سَلَّمَ عَلَيْهِمْ ثُمَّ قَامَ هَؤُلَاءِ فَقَضَوْا رَكْعَتَهُمْ وَقَامَ هَؤُلَاءِ فَقَضَوْا رَكْعَتَهُمْ