"deliberate erotic self-stimulation," 1711 (earlier as mastupration, 1620s), from French masturbation and directly from Modern Latin masturbationem (nominative masturbatio), noun of action from past-participle stem of Latin masturbari "to masturbate."
The long-standing speculation is that this Latin word is altered (probably by influence of turbare "to disturb, confuse") from *manstuprare, from manu, ablative of manus "hand" (see manual) + stuprare "defile" (oneself), from stuprum "defilement, dishonor," related to stupere "to be stunned, stupefied" (see stupid). Hence the earliest form of the word in English. But perhaps the first element represents an unattested *mazdo- "penis" [OED]. An earlier technical word for this was onanism. Related: Masturbational.
Farmer and Henley ["Slang and Its Analogues," 1898] lists among the slang terms for "to masturbate" or "masturbation" frig (which they trace to Latin fricare "to rub") to bob; to box the Jesuit; to chuff, to chuffer; to claw; to digitate (of women); to fight one's turkey (Texan); to handle; to indorse; to milk; to mount a corporal and four; to dash one's doodle; and they note that it was "sometimes known as KEEPING DOWN THE CENSUS."