23 So it came to pass, when Joseph had come to his brothers, that they stripped Joseph of his tunic, the tunic of many colors that was on him.
24 Then they took him and cast him into a pit. And the pit was empty; there was no water in it.
25 And they sat down to eat a meal. Then they lifted their eyes and looked, and there was a company of Ishmaelites, coming from Gilead with their camels, bearing spices, balm, and myrrh, on their way to carry them down to Egypt.
26 So Judah said to his brothers, “What profit is there if we kill our brother and conceal his blood?
27 Come and let us sell him to the Ishmaelites, and let not our hand be upon him, for he is our brother and our flesh.” And his brothers listened.
28 Then Midianite traders passed by; so the brothers pulled Joseph up and lifted him out of the pit, and sold him to the Ishmaelites for twenty shekels of silver. And they took Joseph to Egypt.
29 Then Reuben returned to the pit, and indeed Joseph was not in the pit; and he tore his clothes.
30 And he returned to his brothers and said, “The lad is no more; and I, where shall I go?”
31 So they took Joseph’s tunic, killed a kid of the goats, and dipped the tunic in the blood.
32 Then they sent the tunic of many colors, and they brought it to their father and said, “We have found this. Do you know whether it is your son’s tunic or not?”
33 And he recognized it and said, “It is my son’s tunic. A wild beast has devoured him. Without doubt Joseph is torn to pieces.”
34 Then Jacob tore his clothes, put sackcloth on his waist, and mourned for his son many days.
35 And all his sons and all his daughters arose to comfort him; but he refused to be comforted, and he said, “For I shall go down into the grave to my son in mourning.” Thus his father wept for him.
36 Now the Midianites had sold him in Egypt to Potiphar, an officer of Pharaoh and captain of the guard.
The traders who bought Joseph are referred to as Ishmaelites in verse 28 and Midianites in verse 36. Both Ishmael and Midean were sons of Abraham (Genesis 16:15; 25:2) and their descendants often mixed together. The two names are also used interchangeably in Judges 8:22-24.
the grave (v.35) = Sheol — this is the first reference in Scripture of this place of departed spirits.
As the brothers [minus Reuben] were eating, they saw other visitors coming in the distance—a caravan following the regular nearby trade route from the mountains of Gilead down into Egypt. Gilead was a plateau region east of the Jordan and extending down from about the Sea of Galilee to the Dead Se. … It was a lushly forested region, specially known for its balms and spices. — Morris. page 543
While the brothers plotted and bargained to sell Joseph, he was pleading with them to free him and let him live (Genesis 42:21).
Without Reuben’s knowledge, Judah then takes the lead—also showing some compassion (“for he is our brother, our own flesh”)—in selling their brother to Ishmaelite traders on their way down to Egypt—thus already bearing out the enmity God declared in Genesis 16:12 would arise between Ishmael and his brothers (note that, since Ishmael was Joseph’s great-uncle, these Ishmaelites would have been his second cousins, no further than two or three times removed). Continuing the cautionary sub-theme of the potential influence on children of parent patterns of sin, the sons of Jacob in turn try their hand at deception by dipping Joseph’s tunic in the blood of a goat and bringing it to their father, who concludes that a wild beast has devoured Joseph, for whom he then mourns for many days. — Wechsler, page 249.