Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) narrated: We were with the Prophet (peace and blessings be upon him) in a cave at Mina when a snake leapt out at us. The Messenger of Allah (peace and blessings be upon him) said: "Kill it." We rushed towards it, but it got ahead of us. Then the Messenger of Allah (peace and blessings be upon him) said: "It has been protected from your harm just as you have been protected from its harm."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 10113