Allah's Messenger (ﷺ) led the Fear-prayer with one of the two batches of the army while the other (batch) faced the enemy. Then the first batch went away and took places of their companions (i.e. second batch) and the second batch came and he led his second rak`a with them. Then he (i.e. the Prophet: finished his prayer with Taslim and then each of the two batches got up and completed their remaining one rak`a.
Reference: Sahih al-Bukhari 4133 In-book : Book 64, Hadith 177 USC-MSA web (English) : Vol. 5, Book 59, Hadith 456 (deprecated)
Help us gift a modern, ad-free Islamic application for the Muslim Ummah. Your donation will be recorded as Sadaqah Jariyah in your book of deeds, In Sha Allah.