Earlier, they saw a camel-train of Yishma'elim approaching. Who were the Midyani merchants?
Rashi: This was a different group of people. And it teaches us that Yosef was sold a number of times - (a) The brothers pulled Yosef out of the pit and sold him to the Yishma'elim, who sold him to (b) the Midyanim, 1 who sold him (c) to Egypt. 2
Ramban and Seforno: The Midyani merchants hired the Yishme'eli camel-drivers to transport the goods to Egypt on their behalf. 3 Sometimes the Torah refers to the owners, and sometimes to the camel-drivers, though really they are one and the same. 4
Rashbam: The Midyani merchants, who arrived at the pit before the Yishma'elim, pulled Yosef out of the pit and sold him to the Yishma'elim without the knowledge of the brothers (who were eating some distance away from the pit). 5
Moshav Zekenim (25) #1: He was sold to the Midyanim, then to the Yishma'elim, then to the Medanim, who sold him to Egypt. The Medanim are a different nation; Medan and Midyan were two sons of Keturah. See Bereishis 25:2.
Moshav Zekenim (25) #2: The Midyanim are called Yishma'elim since they lived in Yishmael's land.
Moshav Zekenim (25) #3, Rosh: The Midyanim were middlemen in the sale. 6 The Torah considers all of them as if they sold him.
Moshav Zekenim #4: The brothers were arranging a sale to the Yishma'elim. The Midyanim came and offered more money, and purchased him. They then sold him to the Yishma'elim, who sold him to Potifar.
Oznayim la'Torah: The brothers sold Yosef for twenty silver pieces to the Yishma'elim who had no cash, only wax, balsam and lotus, which they were taking to sell in Egypt - but which did not interest the brothers. since all these commodities were readily available in Eretz Kena'an. 7 They were however, interested in the shoes that the Midyanim had with them to sell, so they accepted ten pairs of shoes to the value of twenty silver pieces 8 that the Yishme'lim owed the brothers. Meanwhile, the Midyanim held on to Yosef as a security, until the Yishma'elim would sell Yosef and pay them with the proceeds. 9
Ohr ha'Chayim: The Yishma'elim were not merchants to buy and sell matters other than what they were carrying. They would not buy Yosef! Therefore, Hashem summoned Midyani merchants, who know the value of everything to sell it for a profit. The Yishma'elim bought Yosef only due to them. The expert and the investor are partners in the profit. Therefore, verse 36 can say that the Medanim sold him to Egypt. It says (39:1) that Potifar bought him from the Yishma'elim, for they paid for him.
Malbim: Yehudah intended that the Yishma'elim will take him; Midyanim came first and took him, and sold him to the Yishma'elim.
Ha'Emek Davar: The Yishma'elim rode on camels, and the Midyanim walked. One cannot go in the Midbar without a large group. From afar, the brothers saw only the tall camels. The Midyanim veered from the road when they heard Yosef's cries, or their heart pushed them to look inside the pit. The brothers saw the Midyanim take Yosef, and were pleased.
The brothers made a point of communicating with the Yishma'elim (Refer to 37:25:2:1) rather than with the Midyanim, who were likely to appear in Chevron to sell their merchandise. Rosh - the Midyanim saw the rich Yishma'elim from afar, and bought him when he was still in the pit.
R. Bechayei: Yosef told his brothers "You sold me to Egypt" (45:4), i.e. I was sold through your throwing me into the pit. Rashbam - alternatively, the brothers commanded the Midyanim to pull him out of the pit before selling him to the Yishma'elim. See Oznayim la'Torah, who derives from the Pasuk in Amos, 2:6 that it was the brothers who initially sold Yosef and not the Midyani merchants.
Riva, citing R. Tam: The brothers were afraid to take Yosef from the pit, due to the snakes. The Yishma'elim hired the Midyanim to take him out through witchcraft; we find that the Midyanim who went to Bil'am were witches. Since they took him out, it is as if they sold him. (If they saw the snakes, they should have realized that Yosef survived because he is a Tzadik! Perhaps they thought that he is a snake-charmer, like Riva said above (22) - PF.)
Oznayim la'Torah: See Bereishis 43:1, how the brothers took those very same commodities with them together with others, as a gift for Yosef - even during a time of famine.
Even though Reuven was not present when they sold Yosef, they purchased a pair of shoes for him as well, on the assumption that he would readily agree to the sale - See Oznayim la'Torah, DH 'b'Esrim Kasef' #2.
Oznayim la'Torah: In this way both the Yishma'elim and the Midyanim were involved in the sale of Yosef - and all the Pesukim fall into place.
What are the implications of the words "Va'yimshechu Va'ya'alu"?
She'arim d'R. Hai Ga'on: It implies that Kinyan Meshichah acquires only after one has moved the object away from its original location.
What is the significance of the twenty silver pieces?
Targum Yonasan: The brothers used the money to purchase shoes. 3 (Riva - the Piyut concerning the Emperor of Rome and the ten martyrs, which we read on Yom Kipur, says that they gave him for shoes.)
Hadar Zekenim (based on the Yerushalmi (Shekalim, 2:3): Because each brother received two silver pieces (a half Shekel Kodesh), each year one must give a half-Shekel for Korbanos. 4
These are Kodesh Shekalim which are synonymous with Sela'im. Hadar Zekenim. One Shekel (Sela) equals four Dinarim, so five Shekalim are 20 Dinarim.
Yerushalmi (Shekalim, 2:3): And it is because each of the ten brothers received half a Shekel (Binyamin was not present at the sale) that Yisrael had to give half a Shekel as a Kaparah. See also Ba'al ha'Turim. Mar'eh ha'Panim (2:3) - also Bnei Yosef give; he caused it through his Leshon ha'Ra. Bnei Reuven and Binyamin give, for we follow the majority. Shirei Korban (2:3) - surely, everyone must give to have a share in Korbanos. The amount of Chetzi Shekel is based on the majority.
Moshav Zekenim: "V'Evyon Ba'avur Na'alayim" (Amos 2:6) alludes to this. Riva - Yosef had an amulet, and Gavriel made it into a robe; the brothers demanded extra for the robe, and the Yishmaelim gave shoes for it. (The verse and the Piyut imply that the shoes were for Yosef himself! Also - after seeing that a miracle was done for Yosef, why did they still sell him? - PF)
Someone as beautiful as Yosef is surely worth more than 20 silver pieces!
Moshav Zekenim, Hadar Zekenim from Pirkei d'R. Eliezer: Due to fear in the pit 1 and of the snakes, his appearance changed, and he was sold for only 20 silver pieces.
Bechor Shor: Due to their hatred they were very eager to sell him, and sold him for far less than his real value.
Hadar Zekenim: They sold him for 20 silver pieces for each brother, i.e. 200 in all, like the Gematriya of "v'Evyon Ba'avur Na'alayim" (Amos 2:6).
Rosh (32) #2: The 20 pieces were Zekukim (pure silver - which were worth much more than regular Dinarim).
Rosh (32) #1: His appearance changed, due to moisture in the pit. Also, fear inhibits blood (also this changed his appearance).
Why did the brothers consent to sell Yosef?
Ohr ha'Chayim: Their anger was calmed after they lowered him so much - they knocked him down, stripped him and shamed him, and cast him in the pit. Primarily, they wanted to ensure that his dreams not be fulfilled. Being sold permanently for a slave precluded becoming free, and all the more so greatness!