Answer
✅Answer: Please pay attention to the following narrations:
1 عَلِيُّ بْنُ جَعْفَرٍ فِي كِتَابِهِ عَنْ أَخِيهِ مُوسَى بْنِ جَعْفَر قَالَ: سَأَلْتُهُ عَنْ قَتْلِ النَّمْلَةِ أَ يَصْلُحُ قَالَ لَا تَقْتُلْهَا إِلَّا أَنْ تُؤْذِيَكَ.
📚 Masa'il Ali ibn Ja'far, p. 157
Ali ibn Ja'far said: I asked Musa ibn Ja'far (prayers of Allah be upon him) about killing an ant, whether it is right and correct? He said: 'Do not kill it unless it harms you!'
2 عَنْ عَبْدِ اللَّهِ بْنِ سِنَانٍ عَنْ أَبِي عَبْداللَّه قَالَ: لَا بَأْسَ بِقَتْلِ النَّمْلِ آذَيْنَكَ أَوْ لَمْ يُؤْذِينَكَ.
📚 Mustatrafat al-Sarair, p. 39
Imam Sadiq (prayers of Allah be upon him) said: 'There is no problem with killing ants, whether they harm you or not!'
3 عَنْ مَسْعَدَةَ بْنِ زِيَادٍ قَالَ سَمِعْتُ جَعْفَرَ بْنَ مُحَمَّد يَقُولُ وَ سُئِلَ عَنْ قَتْلِ الْحَيَّاتِ وَ النَّمْلِ فِي الدُّورِ إِذَا آذَيْنَ قَالَ لَا بَأْسَ بِقَتْلِهِنَّ وَ إِحْرَاقِهِنَّ إِذَا آذَيْنَ
📚 Qurb al-Isnad, p. 40
Mas'adah said: I heard Imam Sadiq (prayers of Allah be upon him) being asked about snakes and ants in the house that cause harm, so he said: 'There is no problem with killing and burning them if they cause harm!'
4 عَنِ الْحَسَنِ بْنِ دَاوُدَ الرَّقِّيِّ عن أَبِي عَبْدِ اللَّهِ في حديث قال لَقَدْ أَخْبَرَنِي أَبِي عَنْ جَدِّي أَنَّ رَسُولَ اللَّهِ نَهَى عَنْ قَتْلِ السِّتَّةِ النَّحْلَةِ وَ النَّمْلَةِ وَ الضِّفْدِعِ وَ الصُّرَدِ وَ الْهُدْهُدِ وَ الْخُطَّافِ
Imam Sadiq (prayers of Allah be upon him) said: 'My father narrated to me from my grandfather that the Messenger of Allah (peace be upon him and his family) prohibited the killing of six things: the honeybee, the ant, the frog, the shurad, the hoopoe, and the swallow.'
5 عَنِ الْحَلَبِيِّ أَنَّهُ سَأَلَ أَبَاعَبْدِ اللَّه عَنِ الرَّجُلِ يَقْتُلُ الْبَقَّةَ وَ الْبُرْغُوثَ وَ الْقَمْلَةَ وَ الذُّبَابَ فِي الصَّلَاةِ أَ يَنْقُضُ ذَلِكَ صَلَاتَهُ وَ وُضُوءَهُ قَالَ لَا.
📚 Al-Faqih, Vol. 1, p. 368
Al-Halabi asked Imam Sadiq (prayers of Allah be upon him) about a person who kills mosquitoes, fleas, lice, and flies during prayer, does it invalidate his prayer and his ablution? He said: 'No.'
6 عَنِ الْحُسَيْنِ بْنِ أَبِي الْعَلَاءِ قَالَ: سَأَلْتُ أَبَا عَبْدِ اللَّه عَنِ الرَّجُلِ يَرَى الْحَيَّةَ وَ الْعَقْرَبَ وَ هُوَ يُصَلِّي الْمَكْتُوبَةَ قَالَ يَقْتُلُهُمَا.
📚 Al-Tahdhib, Vol. 2, p. 330
Husayn ibn Abi al-'Ala' said: I asked Imam Sadiq (prayers of Allah be upon him) about someone who sees a snake and a scorpion during the obligatory prayer; the Imam said: 'He kills them!'
7 عَنْ زُرَارَةَ أَنَّهُ قَالَ لِأَبِي جَعْفَرٍ رَجُلٌ يَرَى الْعَقْرَبَ وَ الْأَفْعَى وَ الْحَيَّةَ وَ هُوَ يُصَلِّي أَ يَقْتُلُهَا قَالَ نَعَمْ إِنْ شَاءَ فَعَلَ.
📚 Al-Faqih, Vol. 1, p. 257
Zurarah said to Imam Baqir (prayers of Allah be upon him): 'A person sees a scorpion, a viper, and a snake during prayer, should he kill them?' He said: 'Yes, if he wishes to do so!'
8 عَنْ زُرَارَةَ عَنْ أَبِي عَبْدِ اللَّه قَالَ: لَا بَأْسَ بِقَتْلِ الْبُرْغُوثِ وَ الْقَمْلَةِ وَ الْبَقَّةِ فِي الْحَرَمِ.
📚 Al-Kafi, Vol. 4, p. 364
Imam Sadiq (prayers of Allah be upon him) said: 'There is no problem with killing fleas, lice, and mosquitoes (even) in the sacred precinct (of Mecca)!'
9 عَنْ جَعْفَرِ بْنِ مُحَمَّدٍ عَنْ أَبِيهِ عَنْ عَلِيٍّ قَالَ: يَقْتُلُ الْمُحْرِمُ مَا عَدَا عَلَيْهِ مِنْ سَبُعٍ أَوْ غَيْرِهِ وَ يَقْتُلُ الزُّنْبُورَ وَ الْعَقْرَبَ وَ الْحَيَّةَ وَ النَّسْرَ وَ الذِّئْبَ وَ الْأَسَدَ وَ مَا خَافَ أَنْ يَعْدُوا عَلَيْهِ مِنَ السِّبَاعِ وَ الْكَلْبَ الْعَقُورَ.
📚 Qurb al-Isnad, p. 66
Ali (prayers of Allah be upon him) said: 'A pilgrim in the state of ihram kills what attacks him from predators and others, and he kills bees, scorpions, snakes, vultures, wolves, lions, and what he fears will attack him from predators and a biting dog!'
✅ In the above narrations, the permissibility of killing some animals in case they cause harm or in general has been narrated, although the killing of some of them, including in narration 4️⃣, has been prohibited.