Sunan an-Nasa'i, Book 18, Hadith 27 (In-Book)

It was narrated from Abu Bakrah that: The Prophet offered the fear prayer with those who were behind him, praying two rak'ahs (with them) and two rak'ahs with those who came after them, so the Prophet prayed four rak'ahs and the others each prayed two rak'ahs.

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

sunnah.com