Harming animals, causing them undue pain or making them suffer is not permitted. Yes, Islam does allow us to defend ourselves and kill harmful animals, but this should be done in a way that does not make the animal suffer. Therefore, it is allowed to kill animals that are harmful to one's self or one's belongings, but the condition is that one should not make them suffer, and one should try and minimize the suffering and pain as much as possible. In light of this, if the pepper spray is such that it is extremely harmful and painful for the animal, then one should avoid using it on the animal, especially if there is a less-painful alternative available. Also, in some countries, it is illegal to carry pepper spray; hence it will also not be permitted to use it Islamically, as one has to obey the laws of the land. In conclusion, there are two conditions for the permissibility of using pepper spray and the like as a form of self-defence against harmful animals: 1) One must be allowed to carry and use the spray by law, 2) It should not be extremely harmful to the animal. One should use a less harmful substance as an alternative. As far as using pepper spray for defence against humans, if one fears for one's life or wealth, one must endeavour to protect one's self or one's wealth even by carrying self-defence weapons. However, one should not carry weapons that are illegal.