The Torah’s protocols of war begin with the following verse: "When you go out to battle against your enemies, and see horses, chariots and a nation greater than you..." (Deuteronomy 20).
While there are certain situations in which war is commanded by the Torah (e.g. the commandment to fight and destroy Amalek), this introduction assumes war to be defensive. Why else would an army go out to face forces greater than itself?
God assures the Israelites that He will be with them, a promise that is publicly restated to the soldiers just before battle by a designated Kohain (priest), who declares: "Hear, O Israel, you are about to battle against your enemies. Do not be faint-of-heart, fear not, nor be alarmed or frightened by them, for the Lord, your God, goes with you, to fight for you against your enemies, to save you" (Deuteronomy 20:3-4).
Invoking compassion even in war, the Jewish army was commanded to call out to their enemies in peace. Maimonides (Rabbi Moses ben Maimon) noted that even the seven native Canaanite nations whom God commanded the Jews to annihilate--man, woman, child, and cattle--must first be given the opportunity to surrender and accept Jewish dominion. If they refuse, only then may they be attacked (Maimonides: Kings, Chapter 6:1 and 4).
The command to annihilate the Canaanite nations was as much an issue of survival as winning the war. The Canaanites did not abide by the seven Noahide commandments, which Judaism considers to be the minimum level of civilization. They were thus a constant physical and spiritual threat. And yet, even when battling the Canaanites, Jewish law mandates that their cities may not be completely surrounded in battle, so that at least one escape route is left open for those who wish to flee.