7 They warred against Midian, as Yahweh commanded Moses; and they killed every male. 8 They killed the kings of Midian with the rest of their slain: Evi, and Rekem, and Zur, and Hur, and Reba, the five kings of Midian: Balaam also the son of Beor they killed with the sword. 9 The children of Israel took captive the women of Midian and their little ones; and all their livestock, and all their flocks, and all their goods, they took for a prey. 10 All their cities in the places in which they lived, and all their encampments, they burnt with fire. 11 They took all the spoil, and all the prey, both of man and of animal. 12 They brought the captives, and the prey, and the spoil, to Moses, and to Eleazar the priest, and to the congregation of the children of Israel, to the camp at the plains of Moab, which are by the Jordan at Jericho.

13 Moses, and Eleazar the priest, and all the princes of the congregation, went forth to meet them outside of the camp. 14 Moses was angry with the officers of the army, the captains of thousands and the captains of hundreds, who came from the service of the war. 15 Moses said to them, “Have you saved all the women alive? 16 Behold, these caused the children of Israel, through the counsel of Balaam, to commit trespass against Yahweh in the matter of Peor, and so the plague was among the congregation of Yahweh. 17 Now therefore kill every male among the little ones, and kill every woman who has known man by lying with him. 18 But all the girls, who have not known man by lying with him, keep alive for yourselves.

Matthew Henry's Commentary on Numbers 31:7-18

Commentary on Numbers 31:7-12

(Read Numbers 31:7-12)

The Israelites slew the Kings of Midian. They slew Balaam. God's overruling providence brought him thither, and their just vengeance found him. Had he himself rightly believed what he had said of the happy state of Israel, he would not have thus herded with the enemies of Israel. The Midianites' wicked wiles were Balaam's projects: it was just that he should perish with them, Hosea 4:5. They took the women and children captives. They burnt their cities and castles, and returned to the camp.

Commentary on Numbers 31:13-18

(Read Numbers 31:13-18)

The sword of war should spare women and children; but the sword of justice should know no distinction, but that of guilty or not guilty. This war was the execution of a righteous sentence upon a guilty nation, in which the women were the worst criminals. The female children were spared, who, being brought up among the Israelites, would not tempt them to idolatry. The whole history shows the hatefulness of sin, and the guilt of tempting others; it teaches us to avoid all occasions of evil, and to give no quarter to inward lusts. The women and children were not kept for sinful purposes, but for slaves, a custom every where practised in former times, as to captives. In the course of providence, when famine and plagues visit a nation for sin, children suffer in the common calamity. In this case parents are punished in their children; and for children dying before actual sin, full provision is made as to their eternal happiness, by the mercy of God in Christ.