Imam Bukhari narrates: Abu al-Yaman narrated to us, he said: Shu'aib informed us from al-Zuhri, he said: I asked Shu'aib: Did the Prophet ﷺ pray the prayer of fear? He said: Salim informed me that Abdullah bin Umar said that
I went with the Messenger of Allāh ﷺ in the campaign of Najd, so we encountered the enemy, then we made rows facing them, then the Messenger of Allāh ﷺ stood up and led us in prayer. So one group prayed with him, and the other group remained facing the enemy. The group that was with the Messenger of Allāh ﷺ, he performed ruku with them and two prostrations, then they went to the place of the group that was facing the enemy and had not prayed, then those people came, so the Messenger of Allāh ﷺ performed ruku with them and two prostrations, then he turned the salam. Then each of the two groups stood up, and each performed their own ruku and two prostrations.
٢ حَدَّثَنَا أَبُو اليَمَانِ، قَالَ أَخْبَرَنَا شُعَيْبٌ، عَنِ الزُّهْرِيِّ، قَالَ سَأَلْتُهُ هَلْ صَلَّى النَّبِيُّ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ؟ يَعْنِي صَلاَةَ الخَوْفِ قَالَ أَخْبَرَنِي سَالِمٌ، أَنَّ عَبْدَ اللَّهِ بْنَ عُمَرَ رَضِيَ اللَّهُ عَنْهُمَا، قَالَ
غَزَوْتُ مَعَ رَسُولِ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ قِبَلَ نَجد، فَوَازَيْنَا العَدُوَّ، فَصَافَفْنَا لَهُمْ، فَقَامَ رَسُولُ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ يُصَلِّي لَنَا، فَقَامَتْ طَائِفَةٌ مَعَهُ تُصَلِّي وَأَقْبَلَتْ طَائِفَةٌ عَلَى العَدُوِّ، ورَكَعَ رَسُولُ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ بِمَنْ مَعَهُ وَسَجَدَ سَجْدَتَيْنِ، ثُم انْصَرفُوا مَكَانَ الطَّائِفَةِ الَّتِي لَمْ تُصَلِّ، فَجَاءُوا، فَرَكَعَ رَسُولُ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ بِهِمْ رَكْعَةً وَسَجَدَ سجدَتَين، ثُمَّ سَلَّمَ، فَقَامَ كُلُّ وَاحِدٍ منْهُمْ، فَرَكعَ لِنَفْسِهِ رَكْعَةً وَسَجَدَ سجدَتَيْنِ
Reference: Sahih Al Bukhari 942