“Take vengeance on the Midianites for the Israelites. After that, you will be gathered to your people.”
Avenge the children of Israel of the Midianites,.... For the injury they had done them, by sending their daughters among them, who enticed them to commit uncleanness with them, and then drew them into the worship of their idols, which brought the wrath of God upon them, and for which 24,000 persons were slain.
Num 31:1-2 The Campaign. - After the people of Israel had been mustered as the army of Jehovah, and their future relation to the Lord had been firmly established by the order of sacrifice that was given to them immediately afterwards, the Lord commanded Moses to carry out that hostility to the Midianites which had already been commanded in Num 25:16-18.
Commenting on Numbers 31:1-2