"You shall cut off her hand; you shall not pity her"—Deuteronomy 25:12.
We are forbidden to have pity on one who is pursuing another to kill him. Instead we are commanded to try to stop the pursuer at all costs, and if the effort to stop him is unsuccessful, and the pursuer persists in acting upon his intentions, we must fight him. If possible, we try to prevent him from killing by amputating one of his limbs, blinding him [etc.], and if the only way to stop him is by killing him, then he must be killed.
The same rule applies to a man pursuing a woman (or man) to rape her (or him).
This only applies while the attacker is pursuing the victim. Once the crime has been perpetrated, the criminal may not be summarily executed, but must be brought to court and tried.