Jabir bin Abdullah reported,

We set out with the Messenger of Allah ﷺ until we reached Dhat al-Riqa. He said, whenever we came upon a shady tree, we would leave it for the Messenger of Allah ﷺ.A man from the polytheists came while the sword of the Messenger of Allah ﷺ was hanging on a tree. He took the sword of the Prophet of Allah ﷺ and unsheathed it.He said to the Messenger of Allah ﷺ, "Are you afraid of me?"The Prophet ﷺ replied, "No."The man asked, "Then who will protect you from me?"The Prophet ﷺ answered, "Allah will protect me from you."The companions of the Messenger of Allah ﷺ then threatened the man, so he sheathed the sword and hung it back up.Then the call to prayer was made. The Prophet ﷺ led one group in two units of prayer, then they withdrew, and he led the other group in two units of prayer. So the Messenger of Allah ﷺ prayed four units, while the people prayed two each.

Azami 2909

Sahih

عن جابر، قال

أقبلنا مع رسول الله ﷺ، حتى إذا كنا بذات الرقاع قال كنا إذا أتينا على شجرة ظليلة تركناها لرسول الله ﷺ. قال فجاء رجل من المشركين وسيف رسول الله ﷺ معلق بشجرة، فأخذ سيف نبي الله ﷺ فاخترطه، فقال لرسول الله ﷺ أتخافني؟ قال: لا قال: فمن يمنعك مني؟ قال: الله يمنعني منك قال فتهدده أصحاب رسول الله ﷺ: فأغمد السيف وعلقه، قال: فنودي بالصلاة، فصلى بطائفة ركعتين، ثم تأخروا، وصلى بالطائفة الأخرى ركعتين، قال فكانت الرسول الله ﷺ أربع ركعات، والقوم ركعتان.

الأعظمي 2909صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Prayer of fear
Section
Imam praying four rakah and the follower praying two by two
Numbering
Jami al-Kamil 2909 (2nd edition)
Azami 2909