This is the genealogy of Jesus the Messiah the son of David, the son of Abraham: Abraham was the father of Isaac, Isaac the father of Jacob, Jacob the father of Judah and his brothers, Judah the father of Perez and Zerah, whose mother was Tamar.
MATTHEW 1:1 -3
We find the story of Tamar in Genesis 38. As the chapter opens, Jacob’s son Judah has married a Canaanite woman named Bath-shua, with whom he had three sons, Er, Onan and Shelah. Er, the oldest son, married a Canaanite woman named Tamar, but he died before they had any children. Genesis 38:7 explains, “But Er, Judah’s firstborn, was wicked in the Lord’s sight; so the Lord put him to death.” The exact nature of his wickedness is not given.
Since Er died without children, his birthright as the oldest son passed to his brother, Onan. In accordance with the law of Levirite marriage, Judah then instructed Onan to marry Tamar and “raise up offspring for your brother” (Genesis 38:9). Levirite marriage was a legal provision in which a dead man’s brother would marry the widow, and the first son born to their union would bear the dead man’s name and inherit his land and properties.
The idea of losing the birthright to a child with Tamar did not sit well with Onan. “Onan knew that the child would not be his; so whenever he slept with his brother’s wife, he spilled his semen on the ground to keep from providing offspring for his brother” (v. 10). As a result, he lost the inheritance anyway because “What he did was wicked in the Lord’s sight, so the Lord put him to death also” (v. 11).
Two sons down, only one to go. By law, Judah should have immediately arranged a marriage between Shelah and Tamar. But he used the excuse that Shelah was “too young,” and told Tamar that they would marry when he had grown up.
But time passed. A lot of time. Shelah was grown, but Judah did not fulfill his promise. Shelah was still single, and Tamar was still living as a widow in her father’s house.
The day came when Tamar found out where Judah would be at a certain time, and she decided to fall back on a Hittite legal code. Apparently if there was no brother to provide an heir, the father-in-law was obligated to do so in his place.
She disguised herself and sat beside the road where Judah would see her. Now, it’s not entirely clear whether she actually dressed up as a prostitute, or if Judah just assumed she was. Either way, Judah mistook her for a shrine prostitute, propositioned her, and offered her a goat from his flock as payment. She asked for some pledge she could keep until he sent the goat, and he gave her his seal with its cord and his staff (v. 18).
Later Judah did send the goat, but the friend who took it was unable to locate the woman. Judah decided to just let her keep the seal and staff, and consider it a lesson learned.
But a few months later, he learned that Tamar was pregnant and he became furious. How dare she!? “Judah said, ‘Bring her out and have her burned to death’” (v. 24). But Tamar sent a message to her father-in-law, “I am pregnant by the man who owns these…. See if you recognize whose seal and cord and staff these are” (v. 25).
Immediately Judah recognized them as his. He knew that he was ultimately in the wrong. He said, “She is more righteous than I, since I wouldn’t give her to my son Shelah” (v. 26). Tamar gave birth to twins, Perez and Zerah (vv. 27-20). Perez did go on to inherit the birthright and carry on the line of Judah.
It’s a terrible story of deception and broken promises. It’s a story that reveals the depravity of the human heart. And yet it’s also a story of grace. This woman, who was not an Israelite, and in fact was from a people who became fierce adversaries of Israel, nonetheless secured a spot in the genealogy of the Messiah.
It’s a beautiful picture of how, many years later, God would open the doors of His family to include people from every tribe and nation. It’s a reminder, as the Lexham Bible Dictionary puts it, “that God will accomplish His purpose even if He has to use a Canaanite woman to do it.”
Acts 28:28, “Therefore I want you to know that God’s salvation has been sent to the Gentiles, and they will listen!”
Revelation 7:9-10, “After this I looked, and behold, a great multitude that no one could number, from every nation, from all tribes and peoples and languages, standing before the throne and before the Lamb, clothed in white robes, with palm branches in their hands, and crying out with a loud voice, ‘Salvation belongs to our God who sits on the throne, and to the Lamb!’”
• Relying on The Constant Companionship of The Holy Spirit
• Does God Exist?
• Join the Inner Circle of Friends
 Lexham Bible Dictionary.