Deuteronomy 20:10-21:9
When you approach a town to attack it, you shall offer it terms of peace. If it responds peaceably and lets you in, all the people present there shall serve you at forced labor. If it does not surrender to you, but would join battle with you, you shall lay siege to it; and when the Lord your God delivers it into your hand, you shall put all its males to the sword. You may, however, take as your booty the women, the children, the livestock, and everything in the town--all its spoil--and enjoy the use of the spoil of your enemy, which the Lord your God gives you.
Thus you shall deal with all towns that lie very far from you, towns that do not belong to nations hereabout. In the towns of the latter peoples, however, which the Lord your God is giving you as a heritage, you shall not let a soul remain alive. No, you must proscribe them--the Hittites and the Amorites, the Canaanites and the Perizzites, the Hivites and the Jebusites--as the Lord your God has commanded you, lest they lead you into doing all the abhorrent things that they have done for their gods and you stand guilty before the Lord your God.
When in your war against a city you have to besiege it a long time in order to capture it, you must not destroy its trees, wielding the ax against them. You may eat of them, but you must not cut them down. Are trees of the field human to withdraw before you into the besieged city? Only trees that you know do not yield food may be destroyed; you may cut them down for constructing siegeworks against the city that is waging war on you, until it has been reduced.
If, in the land that the Lord your God is assigning you to possess, someone slain is found lying in the open, the identity of the slayer not being known, your elders and magistrates shall go out and measure the distances from the corpse to the nearby towns. The elders of the town nearest to the corpse shall then take a heifer which has never been worked, which has never pulled in a yoke; and the elders of that town shall bring the heifer down to an everflowing wadi, which is not tilled or sown.
There, in the wadi, they shall break the heifer's neck. The priests, sons of Levi, shall come forward; for the Lord your God has chosen them to minister to Him and to pronounce blessing in the name of the Lord, and every lawsuit and case of assault is subject to their ruling. Then all the elders of the town nearest to the corpse shall wash their hands over the heifer whose neck was broken in the wadi. And they shall make this declaration: "Our hands did not shed this blood, nor did our eyes see it done. Absolve, O Lord, Your people Israel whom You redeemed, and do not let guilt for the blood of the innocent remain among Your people Israel." And they will be absolved of bloodguilt. Thus you will remove from your midst guilt for the blood of the innocent, for you will be doing what is right in the sight of the Lord.