The first precept makes it clear that we should refrain from killing.
However let's say you have an animal (or worse, a human) who is going to die anyway (say from being attacked by another animal, or some incurable disease). He can either die on his own in agony, or you could end his life quickly.
The intention is not to end his life out of hate or anger, but out of love and compassion - and anyway, nothing you or anyone will do will change that their going to die.
Looking through the other questions on the topic, it's clear that you're going to get bad karma for killing something, even if it's (in your head) justified by self-defence or whatever - but in those cases you have a choice of killing vs something bad happening , while in this case you have a choice of killing vs watching die.