2There Judah saw the daughter of a Canaanite man named Shua, and he took her as a wife and slept with her.
3So she conceived and gave birth to a son, and Judah named him Er.
4Again she conceived and gave birth to a son, and she named him Onan.
5Then she gave birth to another son and named him Shelah; it was at Chezib that she gave birth to him.
6Now Judah acquired a wife for Er, his firstborn, and her name was Tamar.
7But Er, Judah’s firstborn, was wicked in the sight of the LORD; so the LORD put him to death.
8Then Judah said to Onan, “Sleep with your brother’s wife. Perform your duty as her brother-in-law and raise up offspring for your brother.”
9But Onan knew that the offspring would not belong to him; so whenever he would sleep with his brother’s wife, he would spill his seed on the ground so that he would not produce offspring for his brother.
10What he did was wicked in the sight of the LORD, so He put Onan to death as well.
— Genesis 38:2-10