Then he cited the ḥadīth of Abū Hurayrah (may Allah be pleased with him): the Prophet ﷺ dispatched a detachment and said, “If you come upon so-and-so and so-and-so”—naming two men—“burn them with fire.” The Companions resolved to do exactly that in obedience to his order. Yet, just before they set out, he said, “Earlier I told you such-and-such, but no one may punish with fire except Allah. If you find them, kill them.” With this second statement the Prophet ﷺ revoked his first: the initial command was to burn them, the later command was to kill them. This shows that when a person deserves capital punishment he is not to be burned; he is to be executed in the ordinary manner indicated by the revealed texts.
The same principle appears in the report transmitted by Abū Dāwūd: the Prophet ﷺ stepped aside to relieve himself and found the Companions with a ḥamrah—a kind of bird—together with its two chicks. They had taken the chicks, whereupon the mother began to circle overhead, as birds customarily hover, cry out, and show distress when their young are seized. Allah has placed mercy for offspring in the hearts of animals, so much so that a beast will lift its hoof lest it harm its young—one of the signs of His wisdom. The Prophet ﷺ therefore ordered that the chicks be released, and they returned them to their mother.
He then passed by an ant colony that had been set on fire and asked, “Who burned this?” They replied, “We did, O Messenger of Allah.” A “colony of ants” (qaryat al-naml) refers to the ants and their burrows together; they had burned it with fire. The Prophet ﷺ said, “It is not fitting for anyone to punish with fire except the Lord of the Fire,” and he forbade them from doing so.
Accordingly, if you have ants in your home you should not burn them. Rather, use something that drives them away—for instance, purified kerosene poured along the stones will, by Allah’s permission, cause them to flee and not return. If their harm cannot be averted except with a pesticide that kills them outright, there is no blame, for this is merely warding off their injury. Otherwise, ants are among the creatures the Prophet ﷺ forbade killing; but if they harm you and their harm cannot be removed except by killing them, then doing so is permissible.