Joseph had been taken to Egypt by the Ishmaelites, who had sold him to Potiphar, an Egyptian who was one of Pharaoh's officers, the commander of the royal guard.
Read & study FBV 39:1And Joseph was brought down to Egypt; and Potiphar, an officer of Pharaoh’s, the captain of the guard, an Egyptian, bought him of the hand of the Ishmaelites, that had brought him down thither.
Read & study ASV 39:1