In the second book of Shmuel chapter 21 Verse 8. King David gives over 2 of the children and 5 of the grandchildren of King Saul children to the Gibeonites to be hanged? How could David have done such an evil deed? I understand there was a famine, but was there no other way?
Judaica Press on verse 6 cites Abravanel that these set of laws (which would forbid turning them over to be killed) only apply to human justice (and the court system). In this case, King David had been commanded by Hashem to rectify the injustice done to the Gibeonites and it was as if they had been condemned by the heavenly court (which accepted the responsibility for the deed)
Alshich rejects this explanation and suggests that because of the profanation of Hashem's Name caused by failure to heed the promise to the Gibeonits, it was permissable to sanctify His Name by turning them over. This is based on the principle that in a time of great religious crisis, one may set aside the law. See the comment of Rashi on verse 10 as to why they were allowed to hang until the rains came (and Israel was forgiven).