Genesis 39:7-39:23
After a time, his master's wife cast her eyes upon Joseph and said, "Lie with me." But he refused. He said to his master's wife, "Look, with me here, my master gives no thought to anything in this house, and all that he owns he has placed in my hands. He wields no more authority in this house than I, and he has withheld nothing from me except yourself, since you are his wife. How then could I do this most wicked thing, and sin before God?" And much as she coaxed Joseph day after day, he did not yield to her request to lie beside her, to be with her.
One such day, he came into the house to do his work. None of the household being there inside, she caught hold of him by his garment and said, "Lie with me!" But he left his garment in her hand and got away and fled outside. When she saw that he had left it in her hand and had fled outside, she called out to her servants and said to them, "Look, he had to bring us a Hebrew to dally with us! This one came to lie with me; but I screamed loud. And when he heard me screaming at the top of my voice, he left his garment with me and got away and fled outside." She kept his garment beside her, until his master came home. Then she told him the same story, saying, "The Hebrew slave whom you brought into our house came to me to dally with me; but when I screamed at the top of my voice, he left his garment with me and fled outside."
When his master heard the story that his wife told him, namely, "Thus and so your slave did to me," he was furious. So Joseph's master had him put in prison, where the king's prisoners were confined. But even while he was there in prison, the LORD was with Joseph: He extended kindness to him and disposed the chief jailer favorably toward him. The chief jailer put in Joseph's charge all the prisoners who were in that prison, and he was the one to carry out everything that was done there. The chief jailer did not supervise anything that was in Joseph's charge, because the LORD was with him, and whatever he did the LORD made successful.