"Thou shalt not commit adultery", one of the Ten Commandments, is found at Exodus 20:14 of the Tanakh and Old Testament. What constitutes adultery is not defined in this passage of the Bible, and has been the subject of debate within Judaism and Christianity.
Several incidents in the Genesis narrative demonstrate that adultery was understood to be a natural phenomenon. These occur in the times of the Patriarchs over a span of about 200 years, the last one occurring more than 400 years before the giving of the law through Moses. In Genesis 12, Abram’s wife Sarai is taken into the Egyptian Pharaoh’s palace after Abram does not disclose her marital status. God inflicts “serious diseases on Pharaoh and his whole household.” Pharaoh realizes it is because Sarai is actually Abram’s wife and tells him, "What is this you have done to me? Why did you not tell me that she was your wife? Why did you say, 'She is my sister,' so that I took her for my wife? Now then, here is your wife; take her, and go."
In Genesis 20, Abraham (renamed after his encounter with the Almighty) has moved to the Negev and again conceals his marriage to Sarah. A local king, Abimelech, intends to marry her. However, God appears to Abimelech in a dream and says: "Behold, you are a dead man because of the woman whom you have taken, for she is a man’s wife."
Years later, Isaac tells the same lie regarding his wife, Rebekah, but Abimelech quickly discovers the truth. Appalled, he confronts Isaac, saying, "Whoever touches this man or his wife shall surely be put to death."
In Genesis 39, a positive example is presented in Joseph, one of Jacob’s twelve sons. He is sold into slavery in Egypt and quickly rises to a prominent and successful position managing the household of Potiphar, a military captain. He resists sexual advances from Potiphar’s wife “day after day,” protesting that he does not wish to betray Potiphar’s trust. One day her advances become physical, and in his effort to escape, Joseph leaves his cloak behind. Potiphar’s wife uses this ‘evidence’ to falsely accuse Joseph of attempted rape and he is imprisoned, losing all but his life. More than two years later Joseph is restored to an even higher position serving Pharaoh himself.
According to Exodus, the law forbidding adultery was codified for the nation of Israel at Mount Sinai. It was one of the Ten Commandments written by the finger of God on stone tablets. Details regarding the administration of the law and additional boundaries on sexual behavior followed. For example, an ordeal was established to prove the guilt or innocence of a wife whose husband suspected her of adultery. Adultery was a capital crime, and if adulterers were caught, at least two witnesses were required before the death penalty would be carried out. Since men were permitted to have multiple wives, adultery was interpreted to consist of sexual relations between a man and a married or betrothed woman who was not his wife. A man who had sexual relations with a woman who was not married or betrothed was not guilty of adultery, per se, but the man was then obligated to marry the woman, unless her father forbid it. Other boundaries on sexual behavior included the prohibition of sexual relations between close relatives, between persons of the same sex, and between people and animals; prostitution was also forbidden. The prohibition of prostitution has been interpreted by rabbinical scholars to preclude sexual relations outside of marriage in general, and a woman who, after getting married, was found to have been promiscuous before marriage faced the death penalty. A woman who was raped was not guilty of breaking the law, provided she cried out for help (which was taken as proof that she did not consent). According to Deuteronomy, the commandment against adultery was reaffirmed as the leadership of Israel passed from Moses to Joshua.