Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
muslim:843bʿAbdullāh b. ʿAbd al-Raḥman al-Dārimī > Yaḥyá / Ibn Ḥassān > Muʿāwiyah / Ibn Salāam > Yaḥyá > Abū Salamah b. ʿAbd al-Raḥman > Jābir

Abu Salama b. 'Abd al-Rahman reported that Jabir told him that he had observed the prayer in danger with the Messenger of Allah ﷺ. The Messenger of Allah ﷺ (first) led one of the two groups in two rak'ah of prayer. and then led the second group in two rak'ah of prayer. So the Messenger of Allah ﷺ observed four rak'ah and led in two rak'ah each of the groups.  

مسلم:٨٤٣bوَحَدَّثَنَا عَبْدُ اللَّهِ بْنُ عَبْدِ الرَّحْمَنِ الدَّارِمِيُّ أَخْبَرَنَا يَحْيَى يَعْنِي ابْنَ حَسَّانَ حَدَّثَنَا مُعَاوِيَةُ وَهُوَ ابْنُ سَلاَّمٍ أَخْبَرَنِي يَحْيَى أَخْبَرَنِي أَبُو سَلَمَةَ بْنُ عَبْدِ الرَّحْمَنِ أَنَّ جَابِرًا

أَخْبَرَهُ أَنَّهُ صَلَّى مَعَ رَسُولِ اللَّهِ ﷺ صَلاَةَ الْخَوْفِ فَصَلَّى رَسُولُ اللَّهِ ﷺ بِإِحْدَى الطَّائِفَتَيْنِ رَكْعَتَيْنِ ثُمَّ صَلَّى بِالطَّائِفَةِ الأُخْرَى رَكْعَتَيْنِ فَصَلَّى رَسُولُ اللَّهِ ﷺ أَرْبَعَ رَكَعَاتٍ وَصَلَّى بِكُلِّ طَائِفَةٍ رَكْعَتَيْنِ