I heard the Messenger of Allah ﷺ say, "An ant bit one of the prophets, so he ordered the ant colony to be burned. Then Allah revealed to him, 'Because a single ant bit you, you have destroyed an entire nation that glorifies Me.'"
حدثنا عتاب قال أخبرنا عبد الله قال أخبرنا يونس عن الزهري قال أخبرني سعيد بن المسيب وأبو سلمة بن عبد الرحمن أن
سمعت رسول الله ﷺ يقول قرصت نملة نبيا من الأنبياء فأمر بقرية النمل فأحرقت فأوحى الله عز وجل إليه في أن قرصتك نملة أهلكت أمة من الأمم تسبح
Its chain of transmission is sahih. Bukhari related it, 4/75, in the book of jihad, "Yahya bin Bukayr told us," following the chapter "If a polytheist burns a Muslim, should he be burned," and Abu Dawud, 5266, in the book of manners, in the chapter on killing ants.