Genesis 39:8-12

39:8 But he refused, saying to his master’s wife, “Look, my master does not give any thought to his household with me here, and everything that he owns he has put into my care. 39:9 There is no one greater in this household than I am. He has withheld nothing from me except you because you are his wife. So how could I do such a great evil and sin against God?” 39:10 Even though she continued to speak to Joseph day after day, he did not respond to her invitation to have sex with her.

39:11 One day he went into the house to do his work when none of the household servants were there in the house. 39:12 She grabbed him by his outer garment, saying, “Have sex with me!” But he left his outer garment in her hand and ran outside.

Genesis 39:20

39:20 Joseph’s master took him and threw him into the prison, the place where the king’s prisoners were confined. So he was there in the prison.