Judah, one of Jacob’s sons marries an unnamed woman. With her he has 3 sons: Er, Onan, and Shelah. Er marries Tamar, but he greatly offended God, so God killed him. Judah then gives Tamar to Onan saying,
“Have intercourse with your brother’s wife, in fulfillment of your duty as brother-in-law, and thus preserve your brother’s line.”
Onan knew that any child conceived with Tamar would be considered his brothers, so every time they had sex, he pulled out. This made God angry, and God killed him. Judah then sent Tamar back to her father’s house, telling her to wait until Shelah grows up. Time passes, and Judah’s wife dies. After he mourns he goes to visit the people who shear his sheep. Tamar is told of his journey, and she takes off her widow’s clothes and wraps herself in a shawl, and waits for Judah to pass. At this point Shelah has grown up, but Tamar has not been given to him. When Judah passes her, he thinks she is a prostitute, and does not recognize her as his daughter-in-law. For the price of a young goat he has sex with Tamar. After, Tamar goes home and back to being a widow. When Judah becomes aware that Tamar is pregnant, she is accused of being a prostitute. Tamar then reveals that it is Judah’s child she is carrying, and he says that she is in the right, because he did not give her to Shelah. Tamar is not burned to death, and has twins.