Source: Genesis 37, 39
Jacob (Israel) had a large family that included twelve sons and one daughter. His favorite child by far was Joseph. One of the many special things that Jacob did for Joseph was to give Joseph a beautiful coat of many colors. Over the years this favoritism that Jacob showed Joseph made Joseph's brothers hate him. Joseph had two dreams that he told his brothers, and after they heard Joseph describe the dreams, their hatred of Joseph grew. In the first dream, Joseph dreamed that he and his brothers were out in the field harvesting grain and binding the grain into sheaves. Joseph's sheave stood up, and the sheaves of his brothers bowed down to it. This made the brothers very angry and they hated Joseph more than before. In the second dream, Joseph dreamed that the sun and the moon and eleven stars bowed down to him. This dream even made Jacob rebuke Joseph, and his brothers grew more hostile towards Joseph.
Some time later, Joseph's brothers moved their father's sheep to Shechem to graze. Jacob sent Joseph to Shechem to check on his brothers. Joseph got to Shechem and discovered that his brothers had moved the flock to Dothan and he went after them. As he approached his brothers, they began to grumble about Joseph. It wasn't long before they had come up with a plan to kill Joseph. The oldest brother, Reuben, persuaded the other brothers to throw Joseph into a nearby pit (a deep hole in the ground) and not kill him. When Joseph got to the brothers, they grabbed him and tore his coat of many colors off him and then threw him into the pit.
The brothers sat down to eat, and as they ate they saw on the horizon a caravan of traders passing by on their way to Egypt. Another of the brothers, Judah, suggested that they sell Joseph to the traders. The brothers agreed to Judah's idea, and they pulled Joseph out of the pit and sold him to the traders for twenty pieces of silver. The traders then took Joseph away with them to Egypt. Reuben, who had earlier convinced his brothers not to kill Joseph, was apparently away when they sold Joseph. When Reuben returned, Joseph was gone and Reuben was very upset. The other brothers took Joseph's coat of many colors and smeared the blood of a young goat on it. They used this coat to convince Jacob that Joseph had been killed by a wild animal. Jacob went into great mourning for Joseph, not knowing that Joseph was alive in Egypt.
When they arrived in Egypt, the traders sold Joseph to Potiphar. Potiphar was the captain of the guard for Pharaoh, the king of Egypt, and was a very important man. Even though Joseph had been sold into slavery, God had not forgotten about Joseph. Everything that Joseph did for Potiphar, God made it to prosper. Potiphar soon noticed that all that Joseph did was very good, and he put Joseph in charge of his entire house. As time passed, Potiphar's wife became attracted to Joseph. She began asking Joseph to be her lover, but Joseph refused. Joseph asked, "how then can I do this great wickedness, and sin against God?". She kept asking for some time, and Joseph continued to refuse. Finally, one day there was nobody in the house but Joseph and Potiphar's wife. She asked one last time, grabbing Joseph's cloak. Joseph ran away, but Potiphar's wife held onto the cloak and pulled it off of Joseph.
Furious at being rejected by Joseph yet again, Potiphar's wife told Potiphar that Joseph had attacked her. Potiphar was very angry, and he put Joseph into prison. Even though things had gone from bad to worse for Joseph, God was with Joseph. God gave Joseph favor with the prison keeper, and the prison keeper put Joseph in charge of all the prisoners. Whatever Joseph did, God made it to prosper. In spite of all that had happened, God still cared for and blessed Joseph. However, the best was yet to come for Joseph.