Parashas Vayeishev · Passuk 37:36
The Midianites,dMidianites Heb. “Medanites.” meanwhile, sold him in Egypt to Potiphar, a courtier of Pharaoh and his prefect.eprefect Precise force of Heb. sar haṭṭabaḥim uncertain.
Torah Temimah points to Sotah 43a / Pinchos and Midyan.
Sefaria — Sotah 43a / Pinchos and Midyan
English: “And the Midyanim sold him” — it was taught: not for nothing did Pinchos go to war against the Midyanim, but to settle the account of his mother’s father, as it is stated: “And the Midyanim sold him.”
Derash on the verse (Bavli sugya) — not a formal named middah of the 13. A later war is motivated by an ancestral wrong named in this verse.
Pinchos’s campaign against Midyan is framed as paying out the injustice of Yosef’s sale by Midyanim.