Numbers 31:1-7

1 The LORD said to Moses,
2 "Get even with the Midianites for what they did to the Israelites. After that you will join your ancestors [in death]."
3 Moses said to the people, "Some of your men must get ready to go to war against the Midianites. The LORD will use them to get even with Midian.
4 Send 1,000 men from each of the tribes of Israel."
5 So 1,000 men from each tribe were supplied from the divisions of Israel--12,000 men ready for war.
6 Then Moses sent them off to war, 1,000 men from each tribe along with Phinehas, son of the priest Eleazar. Phinehas took with him the holy articles and the trumpets for the fanfare.
7 They went to war against Midian, as the LORD commanded Moses, and killed every man.