كتاب السلام
39  
The Book of Greetings
(39)
Chapter: The Prohibition Of Killing Ants
(39)
باب النَّهْىِ عَنْ قَتْلِ النَّمْلِ، ‏‏
Sahih Muslim 2241 c

Abu Huraira reported so many ahadith and one of them was this that Allah' Messenger (ﷺ) said:

When an Apostle from amongst the Apostles of Allah came to sit under a tree an ant bit him. He commanded his luggage to be removed from under the tree and he commanded it to be burnt in the fire and Allah revealed to him:" Why one ant (which had bitten you) was not killed (and why did you burn the others)?
وَحَدَّثَنَا مُحَمَّدُ بْنُ رَافِعٍ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، أَخْبَرَنَا مَعْمَرٌ، عَنْ هَمَّامِ بْنِ مُنَبِّهٍ، قَالَ هَذَا مَا حَدَّثَنَا أَبُو هُرَيْرَةَ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم فَذَكَرَ أَحَادِيثَ مِنْهَا وَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ نَزَلَ نَبِيٌّ مِنَ الأَنْبِيَاءِ تَحْتَ شَجَرَةٍ فَلَدَغَتْهُ نَمْلَةٌ فَأَمَرَ بِجِهَازِهِ فَأُخْرِجَ مِنْ تَحْتِهَا وَأَمَرَ بِهَا فَأُحْرِقَتْ فِي النَّارِ - قَالَ - فَأَوْحَى اللَّهُ إِلَيْهِ فَهَلاَّ نَمْلَةً وَاحِدَةً ‏"‏ ‏.‏
Reference : Sahih Muslim 2241c
In-book reference : Book 39, Hadith 202
USC-MSA web (English) reference : Book 26, Hadith 5569
  (deprecated numbering scheme)