“Did God Command Genocide and Virgin Capture in Numbers 31:15-18?” I was asked this question on Facebook.

To answer this, let’s first look at what the scripture says:

15 And Moses said to them: “Have you kept all the women alive? 16 Look, these women caused the children of Israel, through the counsel of Balaam, to trespass against the Lord in the incident of Peor, and there was a plague among the congregation of the Lord17 Now therefore, kill every male among the little ones, and kill every woman who has known a man intimately. 18 But keep alive for yourselves all the young girls who have not known a man intimately.
Num 31-15-18

The answer is to put this in perspective and context, which requires us to look at several chapters of the book of Numbers.

Starting in Numbers chapters 22-24, we find the story of the Moabites and the Midianites who try to hire Balaam to curse the Israelites. This is followed by a report that they then began to seduce the Israelites to engage in sexual immorality with the women of Moab, and more:

While Israel was staying in the Acacia Grove, the people began to have sexual relations with the women of Moab. The women invited them to the sacrifices for their gods, and the people ate and bowed in worship to their gods. So Israel aligned itself with Baal of Peor, and the Lord’s anger burned against Israel.
Num 25:1-3

Starting with the sexual sin, this led to the people turning from God and bowing to the gods of the Moabites and Midianites. This sin was an offense to God and a violation of the ten commandments that God had already given to the Israelites, specifically:

“You shall have no other gods before me.

“You shall not make for yourself an image in the form of anything in heaven above or on the earth beneath or in the waters below.You shall not bow down to them or worship them; for I, the Lord your God, am a jealous God, punishing the children for the sin of the parents to the third and fourth generation of those who hate me, but showing love to a thousand generations of those who love me and keep my commandments.
Ex 20:3-4

So God, and then Moses directed the punishment on the Israelites for this offense:

Then the Lord said to Moses, “Take all the leaders of the people and hang the offenders before the Lord, out in the sun, that the fierce anger of the Lord may turn away from Israel.”

So Moses said to the judges of Israel, “Every one of you kill his men who were joined to Baal of Peor.”
Num 25:4-5

This is followed by an Israelite parading a Midianite woman before Moses and the whole community:

And indeed, one of the children of Israel came and presented to his brethren a Midianite woman in the sight of Moses and in the sight of all the congregation of the children of Israel, who were weeping at the door of the tabernacle of meeting.
Num 25:6

This brought about a plague that killed 24,000 people (v9) that was stopped when Phinehas killed the Israelite and the Midianite woman, the latter of which was the daughter of the “head of the people of a father’s house in Midian” (v15).

So the Israelites were not immune to the consequences of this offense. Then God commanded the Israelites to attack the Midianites:

16 The Lord told Moses: 17 “Attack the Midianites and strike them dead. 18 For they attacked you with the treachery that they used against you in the Peor incident. They did the same in the case involving their sister Cozbi, daughter of the Midianite leader who was killed the day the plague came at Peor.”
Num 25:16-18

There’s a detour in the next couple of chapters for a census and regulations for offerings, and then we come to the war with Midian in Num 31 that the questioner referenced. It starts with what God says and Moses elaborates:

And the Lord spoke to Moses, saying: “Take vengeance on the Midianites for the children of Israel. Afterward you shall be gathered to your people.”

So Moses spoke to the people, saying, “Arm some of yourselves for war, and let them go against the Midianites to take vengeance for the Lord on Midian.
Num 31:1-3

Now notice that God’s command was simply to wage war against the Midianites.

Over the next couple of verses, Israel gathers the army in an orderly fashion, and wages war against the Midianites.

And the children of Israel took the women of Midian captive, with their little ones, and took as spoil all their cattle, all their flocks, and all their goods. 10 They also burned with fire all the cities where they dwelt, and all their forts. 11 And they took all the spoil and all the booty—of man and beast.
Num 31:9-11

The children of Israel then brought all of this before Moses and the leaders of Israel. They weren’t commanded to keep any of this. God’s command was simply to wage war (“Attack the Midianites and strike them dead” (Num 25:16) and “Take vengeance on the Midianites for the children of Israel” (Num 31:2)). The children of Israel were the ones that “they took all the spoil and all the booty—of man and beast” (Num 31:11). 

And Moses was angry. It’s in this context, that Moses, not God, but Moses says:

15 And Moses said to them: “Have you kept all the women alive? 16 Look, these women caused the children of Israel, through the counsel of Balaam, to trespass against the Lord in the incident of Peor, and there was a plague among the congregation of the Lord17 Now therefore, kill every male among the little ones, and kill every woman who has known a man intimately. 18 But keep alive for yourselves all the young girls who have not known a man intimately.

So why were the virgins spared? Because none of them had been involved in seducing Israel away from God to Baal of Peor. As John H. Sailhamer says in The Pentateuch as Narrative: A Biblical-Theological Commentary:

Moses’ harsh solution is explained by a reference to the plague which struck 24,000 people during the previous apostacy with the Moabite and Midianite women.
Pg 417-418

Did the command come from God? There’s nothing in there that says that it did. Rather, it came from Moses.