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.
bukhari:3317ʿAbdah b. ʿAbdullāh > Yaḥyá b. Ādam > Isrāʾīl > Manṣūr > Ibrāhīm > ʿAlqamah > ʿAbdullāh

Once we were in the company of Messenger of Allah ﷺ in a cave. Surat-al-Mursalat (77) was revealed there, and we were learning it from Messenger of Allah ﷺ . Suddenly a snake came out of its hole and we rushed towards it to kill it, but it hastened and entered its hole before we were able to catch it. Messenger of Allah ﷺ said," It has been saved from your evil and you have been saved from its evil."  

البخاري:٣٣١٧حَدَّثَنَا عَبْدَةُ بْنُ عَبْدِ اللَّهِ أَخْبَرَنَا يَحْيَى بْنُ آدَمَ عَنْ إِسْرَائِيلَ عَنْ مَنْصُورٍ عَنْ إِبْرَاهِيمَ عَنْ عَلْقَمَةَ عَنْ عَبْدِ اللَّهِ قَالَ

كُنَّا مَعَ رَسُولِ اللَّهِ ﷺ فِي غَارٍ فَنَزَلَتْ {وَالْمُرْسَلاَتِ عُرْفًا} فَإِنَّا لَنَتَلَقَّاهَا مِنْ فِيهِ إِذْ خَرَجَتْ حَيَّةٌ مِنْ جُحْرِهَا فَابْتَدَرْنَاهَا لِنَقْتُلَهَا فَسَبَقَتْنَا فَدَخَلَتْ جُحْرَهَا فَقَالَ رَسُولُ اللَّهِ ﷺ وُقِيَتْ شَرَّكُمْ كَمَا وُقِيتُمْ شَرَّهَا وَعَنْ إِسْرَائِيلَ عَنِ الأَعْمَشِ عَنْ إِبْرَاهِيمَ عَنْ عَلْقَمَةَ عَنْ عَبْدِ اللَّهِ مِثْلَهُ قَالَ وَإِنَّا لَنَتَلَقَّاهَا مِنْ فِيهِ رَطْبَةً وَتَابَعَهُ أَبُو عَوَانَةَ عَنْ مُغِيرَةَ وَقَالَ حَفْصٌ وَأَبُو مُعَاوِيَةَ وَسُلَيْمَانُ بْنُ قَرْمٍ عَنِ الأَعْمَشِ عَنْ إِبْرَاهِيمَ عَنِ الأَسْوَدِ عَنْ عَبْدِ اللَّهِ  


See similar narrations below:

Collected by Nasāʾī's Kubrá
nasai-kubra:11578Aḥmad b. Sulaymān b. ʿAbd al-Malik > Yaḥyá b. Ādam > Isrāʾīl > Manṣūr And al-Aʿmash > Ibrāhīm > ʿAlqamah > ʿAbdullāh

[Machine] We were with the Messenger of Allah ﷺ in a cave, and the female messengers were sent down upon him. We used to receive revelation from within the cave when a snake came out towards us, so we killed it. The Messenger of Allah ﷺ said, "Your evil has been averted just as its evil was averted." Al-A'mash added in his narration: Abdullah said, "We used to receive revelation from within the cave in a moist atmosphere." Abu Abdur-Rahman disagreed with him, and said that Hafs ibn Ghiyath narrated it from Al-A'mash, from Ibrahim, from Al-Aswad.  

الكبرى للنسائي:١١٥٧٨أَخْبَرَنَا أَحْمَدُ بْنُ سُلَيْمَانَ بْنِ عَبْدِ الْمَلِكِ حَدَّثَنَا يَحْيَى بْنُ آدَمَ عَنْ إِسْرَائِيلَ عَنْ مَنْصُورٍ وَالْأَعْمَشِ عَنْ إِبْرَاهِيمَ عَنْ عَلْقَمَةَ عَنْ عَبْدِ اللهِ قَالَ

كُنَّا مَعَ رَسُولِ اللهِ ﷺ فِي غَارٍ وَأُنْزِلَتْ عَلَيْهِ وَالْمُرْسَلَاتِ عُرْفًا فَإِنَّا لَنَتَلَقَّاهَا مِنْ فِيهِ إِذْ خَرَجَتْ عَلَيْنَا حَيَّةٌ فَابْتَدَرْنَاهَا فَدَخَلَتْ جُحْرَهَا فَقَالَ رَسُولُ اللهِ ﷺ «وُقِيَتْ شَرَّكُمْ كَمَا وُقِيتُمْ شَرَّهَا» زَادَ الْأَعْمَشُ فِي حَدِيثِهِ قَالَ عَبْدُ اللهِ إِنَّا لَنَتَلَقَّاهَا مِنْ فِيهِ رَطْبَةً قَالَ أَبُو عَبْدِ الرَّحْمَنِ خَالَفَهُ حَفْصُ بْنُ غِيَاثٍ رَوَاهُ عَنِ الْأَعْمَشِ عَنْ إِبْرَاهِيمَ عَنِ الْأَسْوَدِ