Old English sceaft "long, slender rod, staff, pole; spear-shaft; spear," from Proto-Germanic *skaftaz (source also of Old Norse skapt, Old Saxon skaft, Old High German scaft, German schaft, Dutch schacht, not found in Gothic), which some connect with a Germanic passive past participle of PIE root *(s)kep- "to cut, to scrape" (source of Old English scafan "to shave, scrape, polish") on notion of "tree branch stripped of its bark." But compare Latin scapus "shaft, stem, shank," Greek skeptron "a staff" (see scepter) which appear to be cognates.
Meaning "beam or ray" (of light, etc.) is attested from c. 1300. Sense of "an arrow" is from c. 1400; that of "a handle" from 1520s. Mechanical sense is from 1680s. Vulgar slang meaning "penis" first recorded 1719 on notion of "columnar part" (late 14c.); hence probably shaft (v.) and the related noun sense "act of unfair treatment" (1959), though some early sources insist this is from the notion of a "wound."
"long, narrow passage sunk into the earth," early 15c., probably from shaft (n.1) on notion of "long and cylindrical," perhaps as a translation of cognate Low German schacht in this sense (Grimm's suggestion, though OED is against it). Or it may represent a separate (unrecorded) development in Old English directly from Proto-Germanic *skaftaz if the original sense is "scrape, dig." The slang sense of shaft (n.1) is punned upon in country music song "She Got the Gold Mine, I Got the Shaft," a hit for Jerry Reed in 1982.
"treat cruelly and unfairly," by 1958, perhaps from shaft (n.1) with overtones of sodomy. Related: Shafted; shafting.