(Bamidbar 31:1-2) "And the L-rd spoke to Moses, saying: Take the revenge of the children of Israel, etc.": This is in praise of the leaders of Israel. They do not depart from the world until they take Israel's revenge, which is the revenge of Him who spoke and brought the world into being. "from the Midianites": But were the Moavites not the initiators? As it is written (Bamidbar 22:4) "And Moav said to the elders of Midian, etc." and (Ibid. 7) "And the elders of Moav went and the elders of Midian, etc." They had never made peace with each other — except when it came to warring with Israel.

An analogy: Two sheep dogs were always at odds with each other, until a wolf came to snatch a lamb from the flock, when one of them, standing up against it, the other said: If I don't help him now, he will kill the lamb and then will turn against me and kill me — whereupon they made peace with each other and took on the wolf. Likewise, Moav and Midian were never at peace with each other, viz. (Bereshit 36:35) "… who smote Midian in the field of Moav."

But when they came to make war against Israel, they made peace with each other. Why, then, "from the Midianites"? For they "counseled" against Israel. "the Midianites" — they "inveighed" ("midaynin") against Israel.