Abdullah bin Masud reported,

He said, we were with the Prophet ﷺ in a cave when "By those sent forth in succession" [Mursalat 77:1] was revealed to him, and we were learning it directly from his mouth while it was still fresh, when suddenly a snake appeared before us.He said, "Kill it!"We rushed to kill it, but it escaped us.The Messenger of Allah ﷺ said, "Allah has protected it from your harm just as He has protected you from its harm."

Azami 14851

Sahih

عن عبد الله بن مسعود، قال

قال: كنا مع النبي ﷺ في غار، وقد أنزلت عليه {والمرسلت عرفا} فنحن نأخذها من فيه رطبة، إذ خرجت علينا حية، فقال: اقتلوها فابتدرناها، لنقتلها، فسبقتنا، فقال رسول الله ﷺ: وقاها الله شركم كما وقاكم شرها.

الأعظمي 14851صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Superior moral conduct
Chapter
Kindness to animals
Section
Killing snakes
Numbering
Jami al-Kamil 14851 (2nd edition)
Azami 14851