While we were with the Messenger of Allah ﷺ in a cave, "By the winds sent forth" [Mursalat 77:1] was revealed to him. We received it directly from his mouth, and his mouth was still fresh with it when a snake suddenly appeared.The Messenger of Allah ﷺ said, "Kill it!"We rushed to strike it, but it escaped us. He then said, "It has been spared your harm, just as you have been spared its harm."
بينا نحن مع رسول الله ﷺ غار إذ نزلت عليه: {والمرسلت}، فتلقيناها من فيه، وإن فاه لرطب بها إذ خرجت حية، فقال رسول الله ﷺ: عليكم اقتلوها قال: فابتدرناها فسبقتنا، قال: فقال: وقيت شركم كما وقيتم شرها.
Bukhari related it in the tafsir (4931) and Muslim in the salam (2234), both from the hadith of Qutayba bin Saeed, who said, Jareer narrated to us, from Amash, from Ibrahim, from Aswad, who said, Abdullah bin Masud said, and then he mentioned it, and the wording is Bukhari's, for Muslim did not give the wording with this chain, but instead referred back to the chain preceding it. Bukhari added (4934), in a narration from another route from Amash, with the same chain, "in a cave at Mina."