Onanism is an archaic term for masturbation, sometimes used metaphorically for self-indulgence.

The term comes from the story of Onan in the Bible (Genesis 38:7-9). After his older brother Er died he was required to marry Er's widow Tamar (this was the practice of levirate marriage). According to the Bible, whenever he had sexual intercourse with his brother's wife he spilt his semen upon the ground (probably a reference to coitus interruptus); the Bible says that he did this because (under the custom of levirate marriage) the child would not be considered his, but his late brother's. In response to this transgression, God killed Onan.

Since ancient times, both Jewish and Christian authors have interpreted this passage as a condemnation of masturbation. Most modern biblical scholars, however, say that Onan's sin was to violate the rules of levirate marriage, a Biblical law which states that a childless widow must marry her late husband's brother.