The Ruling on Killing Ants and Cockroaches Found in the House
Shaikh Bin Baz rahimahullah said:
“If harm comes from these insects, then they are killed using the different types 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 that the legality of killing these mentioned things and its meaning is in regards to the harmful things like the ants or 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”.
[Taken from: http://islamancient.com/play.php?catsmktba=8868%5D
Faisal Ibn Abdul Qaadir Ibn Hassan