But the traders from Midian sold Joseph to Potiphar in Egypt. Potiphar was one of Pharaoh's officials. He was the captain of the palace guard.
The Lord was with Joseph. He gave him great success. Joseph lived in Potiphar's house. ... So Potiphar was pleased with Joseph. He made him his attendant. He put Joseph in charge of his house.
... When Joseph's master heard her story, he became very angry. So he put Joseph in prison.
... So the man who was running the prison was pleased with Joseph. He put Joseph in charge of all of the prisoners.
"Here's what your dream means," Joseph said to him. ... In three days Pharaoh will let you out of prison. He'll give your position back to you. And you will put Pharaoh's cup in his hand. ..."But when everything is going well with you, remember me. Do me a favor. Speak to Pharaoh about me. Get me out of this prison. I was taken away from the land of the Hebrews by force. Even here I haven't done anything to be put in prison for."
Everything happened exactly as Joseph had told them when he explained their dreams. But the chief wine taster didn't remember Joseph. ...
When two full years had passed, Pharaoh had a dream. ...So Pharaoh sent for Joseph. He was quickly brought out of the prison.
...So Pharaoh said to Joseph, "I'm putting you in charge of the whole land of Egypt."
(New International Reader's Version)
"Being sold into slavery served two sets of purposes in Joseph's life. His brothers sold him to be rid of him, and their purpose was served. But God allowed it for his own purpose, to save the people of Israel alive. Unless the grace of God later intervened, the brothers would answer for their evil purpose. But that did not keep them from serving God's purpose. They did so as surely as if that was all they wanted to do!" (Tom Wells)
God's involvement and guidance in Joseph's life is indirect and probably a little mystifying to Joseph. At times it probably seems to him that he is living in an upside down unjust world. He seems to get the exact opposite of what he deserves. He tells his family about his dreams and they throw him in a well and sell him into slavery. He resists sexual advances from his boss's wife and ends up in prison. He interprets another dream to help a cell mate and that guy forgets about him when he gets out. He could easily be saying "I give up, life isn't fair!" Yet Joseph never gives up and keeps moving forward. He does his best wherever he finds himself. He remains patient and trusts God. Joseph could see God's hand in the tragedies of his life. Sold into slavery - new powerful career in Egypt. Loses his position and is thrown into prison - raised up to second in command to Pharaoh and soon the opportunity to save his own family from starvation. God has a purpose. His purpose is much larger than we can see at any given point.