"horse used for breeding," Old English stod "herd of horses, place where horses are kept for breeding," from Proto-Germanic *stodo (source also of Old Norse stoð, Middle Low German stod, Old High German stuot "herd of horses," German Stute "mare"), from PIE root *sta- "to stand, make or be firm," with derivatives meaning "place or thing that is standing" (source also of Old Church Slavonic stado "herd," Lithuanian stodas "a drove of horses").
Sense of "male horse kept for breeding" is first recorded 1803; meaning "man who is highly active and proficient sexually" is attested from 1895; that of "any young man" is from 1929. Stud-poker (1864) is said to be from stud-horse poker, but that phrase is not found earlier than 1879.