About that time Judah left his brothers and went to stay with a man named Hirah, who was from the town of Adullam.
There Judah met a young Canaanite woman whose father was named Shua. He married her,
and she bore him a son, whom he named Er.
She became pregnant again and bore another son and named him Onan.
Again she had a son and named him Shelah. Judah was at Achzib when the boy was born.
For his first son Er, Judah got a wife whose name was Tamar.
Er's conduct was evil, and it displeased the Lord, so the Lord killed him.
Then Judah said to Er's brother Onan, "Go and sleep with your brother's widow. Fulfill your obligation to her as her husband's brother, so that your brother may have descendants."
But Onan knew that the children would not belong to him, so when he had intercourse with his brother's widow, he let the semen spill on the ground, so that there would be no children for his brother.
What he did displeased the Lord, and the Lord killed him also.
Then Judah said to his daughter-in-law Tamar, "Return to your father's house and remain a widow until my son Shelah grows up." He said this because he was afraid that Shelah would be killed, as his brothers had been. So Tamar went back home.
After some time Judah's wife died. When he had finished the time of mourning, he and his friend Hirah of Adullam went to Timnah, where his sheep were being sheared.
Someone told Tamar that her father-in-law was going to Timnah to shear his sheep.
So she changed from the widow's clothes she had been wearing, covered her face with a veil, and sat down at the entrance to Enaim, a town on the road to Timnah. As she well knew, Judah's youngest son Shelah was now grown up, and yet she had not been given to him in marriage.
When Judah saw her, he thought that she was a prostitute, because she had her face covered.
He went over to her at the side of the road and said, "All right, how much do you charge?" (He did not know that she was his daughter-in-law.) She said, "What will you give me?"
He answered, "I will send you a young goat from my flock." She said, "All right, if you will give me something to keep as a pledge until you send the goat."
"What shall I give you as a pledge?" he asked. She answered, "Your seal with its cord and the walking stick you are carrying." He gave them to her. Then they had intercourse, and she became pregnant.
Tamar went home, took off her veil, and put her widow's clothes back on.
Judah sent his friend Hirah to take the goat and get back from the woman the articles he had pledged, but Hirah could not find her.
He asked some men at Enaim, "Where is the prostitute who was here by the road?" "There has never been a prostitute here," they answered.
He returned to Judah and said, "I couldn't find her. The men of the place said that there had never been a prostitute there."
Judah said, "Let her keep the things. We don't want people to laugh at us. I did try to pay her, but you couldn't find her."
About three months later someone told Judah, "Your daughter-in-law Tamar has been acting like a whore, and now she is pregnant." Judah ordered, "Take her out and burn her to death."
As she was being taken out, she sent word to her father-in-law: "I am pregnant by the man who owns these things. Look at them and see whose they are - this seal with its cord and this walking stick."
Judah recognized them and said, "She is in the right. I have failed in my obligation to her - I should have given her to my son Shelah in marriage." And Judah never had intercourse with her again.
When the time came for her to give birth, it was discovered that she was going to have twins.
While she was in labor, one of them put out an arm; the midwife caught it, tied a red thread around it, and said, "This one was born first."
But he pulled his arm back, and his brother was born first. Then the midwife said, "So this is how you break your way out!" So he was named Perez.
References for Genesis 38:29
Then his brother was born with the red thread on his arm, and he was named Zerah.
References for Genesis 38:30