From Genesis, Chapter 39:

Now Joseph was handsome in form and appearance. And after a time his master's wife cast her eyes on Joseph and said, “Lie with me.” But he refused and said to his master's wife, “Behold, because of me my master has no concern about anything in the house, and he has put everything that he has in my charge. He is not greater in this house than I am, nor has he kept back anything from me except you, because you are his wife. How then can I do this great wickedness and sin against God?” And as she spoke to Joseph day after day, he would not listen to her, to lie beside her or to be with her.

But one day, when he went into the house to do his work and none of the men of the house was there in the house, she caught him by his garment, saying, “Lie with me.” But he left his garment in her hand and fled and got out of the house. And as soon as she saw that he had left his garment in her hand and had fled out of the house, she called to the men of her household and said to them, “See, he has brought among us a Hebrew to laugh at us. He came in to me to lie with me, and I cried out with a loud voice. And as soon as he heard that I lifted up my voice and cried out, he left his garment beside me and fled and got out of the house.” Then she laid up his garment by her until his master came home, and she told him the same story, saying, “The Hebrew servant, whom you have brought among us, came in to me to laugh at me. But as soon as I lifted up my voice and cried, he left his garment beside me and fled out of the house.”

As soon as his master heard the words that his wife spoke to him, “This is the way your servant treated me,” his anger was kindled. And Joseph's master took him and put him into the prison, the place where the king's prisoners were confined, and he was there in prison.

TL;DR: She wanted him, he turned her down, she had him thrown in jail to save her own skin.