The Onan reference article from the English Wikipedia on 24-Apr-2004
(provided by Fixed Reference: snapshots of Wikipedia from wikipedia.org)

Onan

Onan is a person described in the Bible e.g. at (Genesis 38:7-9). His name is the origin for the sexual term onanism which is nowadays considered as a misleading construction.

After his older brother Er died Onan 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.

Ancient times authors (Jewish and Christian) did understand the activities of god in this story as condemnation of masturbation. Most modern biblical scholars, however, say that Onan's sin was to violate the rules of levirate marriage, the Biblical law which states that a childless widow must marry her late husband's brother.

It is now generally agreed that the passage refers to coitus interruptus rather than onanism or masturbation.