Shaikh Bin Baz rahimahullah said:
“If harm comes from these insects, then they are killed using the different types of removing agents besides using fire due to the statement of the Prophet sallalahu alayhi wa salam:
“Five animals are wicked and are allowed to be killed in and out of the state of ihram:
- the crow
- the kite
- the mouse
- the scorpion
- and the wild animal which poses a threat”.
There comes another Saheeh Hadith which mentions the snake.
This Hadith is authentic from the Prophet sallahu alayhi wa salam proves the legality of killing these mentioned things and its meaning is in regards to the harmful things like the ants, cockroaches, mosquitoes, flies, and wild animals out of defense against their harms.
As for if the ant does not harm, then the Prophet sallalahu alayhi wa salam prohibited killing the ant, bee, hoopoe bird, and shrike. That is if it does not harm anything. If it does harm, then these five mentioned in the Hadith are joined to the permissibility to kill”.
Faisal Ibn Abdul Qaadir Ibn Hassan