Sunan an-Nasa'i, Hadith 836

837. It was narrated from Abu Bakr that the Prophet offered the fear prayer (Salat Al-Khauf). He led those who were behind him in two Rak'ah and those who came (after them) in two Rak'ah, so the Prophet prayed four Rak'ahs and each group prayed two.

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

sunnah.com