When Joseph was taken to Egypt by the Ishmaelite traders, he was purchased by Potiphar, an Egyptian officer. Potiphar was captain of the guard for Pharaoh, the king of Egypt.
Then, just as they were sitting down to eat, they looked up and saw a caravan of camels in the distance coming toward them. It was a group of Ishmaelite traders taking a load of gum, balm, and aromatic resin from Gilead down to Egypt.
So when the Ishmaelites, who were Midianite traders, came by, Joseph’s brothers pulled him out of the cistern and sold him to them for twenty pieces of silver. And the traders took him to Egypt.
Meanwhile, the Midianite traders arrived in Egypt, where they sold Joseph to Potiphar, an officer of Pharaoh, the king of Egypt. Potiphar was captain of the palace guard.