Euthanasia and Buddhism 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.
I've been to a lecture in which a Tibetan Buddhist monk (specifically, a nyingmapa) was asked the same question by a teenage girl. Basically, his answer was, such killing would both end some existing suffering and create some new suffering. Because regular person does not see all complexity of karma network spanning multiple lives, his or her acts are very likely to make the karmic situation even worse.

According to that monk, compassionate killing should be left to either dakas/dakinis (the crazy yogis capable of "eating icecream and shit at the same time" -- i.e. skilfully dealing with consequences of the bad karma they take on) or omniscient buddhas who can grant liberation at the time of killing, or at least create a favorable karmic condition in subsequent lives.