While Judah did have sexual relations with a woman he thought was a harlot, in reality she was not a harlot.
At that time, brother-in-law marriage was practiced. This required that when a man died without an heir, his brother was to provide the widow with the basis for an heir. Before Judah’s firstborn son had any sons by his wife, Tamar, he was put to death because he proved to be bad in the eyes of Jehovah. Judah’s second son, Onan, refused to fulfill his obligation of brother‐in‐law marriage. So, he died as a result of divine judgment.
Judah then sent Tamar back to her father’s home until the time Judah’s third son, Shelah, was old enough to be united with her. But as the years went by,
Judah failed to give Shelah in marriage to Tamar. So when Judah lost his wife in death, Tamar devised a plan to get an heir by Judah.
When the truth came out, Judah did not blame Tamar, but humbly said: “She is more righteous than I am, for the reason that I did not give her to Shelah my son.” (
Genesis 38:26)
Judah acted wrongly in that he did not give Tamar to his third son, Shelah, as promised. He also had relations with a woman he thought was a temple prostitute. This was contrary to God’s purpose, which was for a man to have sexual relations only in the marriage arrangement. (
Genesis 2:24) In reality, though, Judah did not have relations with a harlot. Rather, he unwittingly took the place of his son Shelah in performing brother-in-law marriage and thus fathered legal offspring.
As for Tamar, her course was not an immoral one and her twin sons were not considered to be the sons of fornication. (Matthew 1:1-3)