Then Judah said to Er's brother Onan, "Go and sleep with your dead brother's wife. Become like a husband to her. If children are born, they will belong to your brother Er."
Onan knew that the children from this union would not belong to him. He had sexual relations with Tamar, but he did not allow himself to stay inside her.
Then Judah said to his daughter-inlaw Tamar, "Go back to your father's house. Stay there and don't marry until my young son Shelah grows up." Judah was afraid that Shelah would also be killed like his brothers. So Tamar went back to her father's home.
Later, Judah's wife, the daughter of Shua, died. After Judah's time of sadness, he went to Timnah with his friend Hirah from Adullam. Judah went to Timnah to have the wool cut from his sheep.
Tamar always wore clothes that showed that she was a widow. So she put on some different clothes and covered her face with a veil. Then she sat down near the road going to Enaim, a town near Timnah. Tamar knew that Judah's younger son Shelah was now grown up, but Judah would not make plans for her to marry him.
So he went to her and said, "Let me have sex with you." (Judah did not know that she was Tamar, his daughter-inlaw.) She said, "How much will you give me?"
Judah answered, "I will send you a young goat from my flock." She answered, "I agree to that. But first you must give me something to keep until you send me the goat."
Judah asked, "What do you want me to give you as proof that I will send you the goat?" Tamar answered, "Give me your seal and its string and your walking stick." Judah gave these things to her. Then Judah and Tamar had sexual relations, and she became pregnant.
Later, Judah sent his friend Hirah to Enaim to give the prostitute the goat he promised. Judah also told Hirah to get the special seal and the walking stick from her, but Hirah could not find her.
He asked some of the men at the town of Enaim, "Where is the prostitute who was here by the road?" The men answered, "There has never been a prostitute here."
So Judah's friend went back to Judah and said, "I could not find the woman. The men who live in that place said that there was never a prostitute there."
About three months later, someone told Judah, "Your daughter-in-law Tamar sinned like a prostitute, and now she is pregnant." Then Judah said, "Take her out and burn her."
The men went to Tamar to kill her, but she sent a message to her father-in-law that said, "The man who made me pregnant is the man who owns these things. Look at them. Whose are they? Whose special seal and string is this? Whose walking stick is this?"
Judah recognized these things and said, "She is right. I was wrong. I did not give her my son Shelah like I promised." And Judah did not sleep with her again.
But that baby pulled his hand back in, so the other baby was born first. So the nurse said, "You were able to break out first!" So they named him Perez.