Sahih Bukhari Volume 4, Book 54, Hadith Number 534.

Narated By ‘Abdullah : Once we were in the company of Allah’s Apostle in a cave. Surat-al-Mursalat (77) was revealed there, and we were learning it from Allah’s Apostle. 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. Allah’s Apostle said,” It has been saved from your evil and you have been saved from its evil.”