Genesis 37:23-36
When Joseph came up to his brothers, they stripped Joseph of his tunic, the ornamented tunic that he was wearing, and took him and cast him into the pit. The pit was empty; there was no water in it. Then they sat down to a meal. Looking up, they saw a caravan of Ishmaelites coming from Gilead, their camels bearing gum, balm, and ladanum to be taken to Egypt. Then Judah said to his brothers, "What do we gain by killing our brother and covering up his blood? Come, let us sell him to the Ishmaelites, but let us not do away with him ourselves. After all, he is our brother, our own flesh." His brothers agreed. When Midianite traders passed by, they pulled Joseph up out of the pit. They sold Joseph for twenty pieces of silver to the Ishmaelites, who brought Joseph to Egypt.
When Reuben returned to the pit and saw that Joseph was not in the pit, he rent his clothes. Returning to his brothers, he said, "The boy is gone! Now, what am I to do?" Then they took Joseph's tunic, slaughtered a kid, and dipped the tunic in the blood. They had the ornamented tunic taken to their father, and they said, "We found this. Please examine it; is it your son's tunic or not?" He recognized it, and said, "My son's tunic! A savage beast devoured him! Joseph was torn by a beast!" Jacob rent his clothes, put sackcloth on his loins, and observed mourning for his son many days. ALL his sons and daughters sought to comfort him; but he refused to be comforted, saying, "No, I will go down mourning to, my son in Sheol." Thus his father bewailed him.
The Midianites, meanwhile, sold him in Egypt to Potiphar, a courtier of Pharaoh and his chief steward.