At that time (when Joseph was sold as a slave to Potiphar in Egypt), Judah went down from his brothers, and stayed with Hirah, an Adullamite. While there Judah saw a daughter of Shua, a Canaanite. He took her and went in unto her. She conceived and bore a son. Judah called his name Er. She conceived again and bore a son. She called his name Onan. And she conceived yet again and bore a son. She called his name Shelah. Judah was at Chezib when she gave birth to Shelah.
Judah took a wife for Er his firstborn. Her name was Tamar. Er, Judah’s firstborn, was wicked in the sight of the Lord, and the Lord killed him.
Judah (to Onan): Go in unto your brother’s wife and marry her and raise up seed to your brother.
Onan knew that the offspring would not be his. Therefore, when he went in unto his brother’s wife, he spilled his seed on the ground, lest he should give seed to his brother. This thing which he did displeased the Lord: therefore he slew him also.
Judah (to Tamar his daughter in law): Remain a widow at your father’s house till Shelah my son is grown.
Judah (to himself): Lest perhaps he die also, as his brethren did.
And Tamar went and dwelt in her father’s house.