One Buddhist parable tells the story of how 200 passengers were sailing on a ship, but nobody realized when they set off that one of the people on board was a madman intent on sinking the ship and killing everybody, including himself. The ship did not have a brig, or place suitable to confine the madman, and because of his strength, no one could restrain him in any way from carrying out his threat to sink the ship and kill everyone on board.
The captain was a devout Buddhist and knew that it was sinful to kill any being, and also knew that if he did nothing, by obeying the spiritual law to the letter, then all 200 people would die.
Reasoning intelligently, he did the only thing he could do, and killed the madman, thus saving the lives of 199 people on board.
In this way he properly understood the true spirit of the precept and truly obeyed the instruction of Lord Buddha not to kill.