Sunan Abi Dawud, Hadith 1233

Narrated Sahl b. Abi Hathmah: The Prophet prayed in time of danger and divided them (the people) behind him in two rows. He then led those who were near him in one rak'ah. Then he stood and remained standing till those who were in second row offered one rak'ah. Thereafter they came forward and those who were in front of them (in the first row) stepped backward. The Prophet led them in one rak'ah of prayer. He sat down till those who were in the second row completed on rak'ah. He then uttered the salutation.

حَدَّثَنَا عُبَيْدُ اللَّهِ بْنُ مُعَاذٍ، حَدَّثَنَا أَبِي، حَدَّثَنَا شُعْبَةُ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ الْقَاسِمِ، عَنْ أَبِيهِ، عَنْ صَالِحِ بْنِ خَوَّاتٍ، عَنْ سَهْلِ بْنِ أَبِي حَثْمَةَ، أَنَّ النَّبِيَّ صلى الله عليه وسلم صَلَّى بِأَصْحَابِهِ فِي خَوْفٍ فَجَعَلَهُمْ خَلْفَهُ صَفَّيْنِ فَصَلَّى بِالَّذِينَ يَلُونَهُ رَكْعَةً ثُمَّ قَامَ فَلَمْ يَزَلْ قَائِمًا حَتَّى صَلَّى الَّذِينَ خَلْفَهُمْ رَكْعَةً ثُمَّ تَقَدَّمُوا وَتَأَخَّرَ الَّذِينَ كَانُوا قُدَّامَهُمْ فَصَلَّى بِهِمُ النَّبِيُّ صلى الله عليه وسلم رَكْعَةً ثُمَّ قَعَدَ حَتَّى صَلَّى الَّذِينَ تَخَلَّفُوا رَكْعَةً ثُمَّ سَلَّمَ ‏.‏

sunnah.com