In most snake species, males have longer tails than females of the same body length. The adaptive significance of this widespread dimorphism has attracted much speculation, but few tests. We took advantage of huge mating aggregations of red–sided gartersnakes (Thamnophis sirtalis parietalis) in southern Manitoba to test two (non–exclusive) hypotheses about the selective forces responsible for this dimorphism. Our data support both hypotheses. First, relative tail length affects the size of the male copulatory organs (hemipenes). Males with longer tails relative to body length have longer hemipenes, presumably because of the additional space available (the hemipenes are housed inside the tail base). Second, relative tail length affects male mating success. Males with partial tail loss (due to predation or misadventure) experienced a threefold reduction in mating success. Among males with intact tails, we detected strong stabilizing selection on relative tail length in one of the two years of our study. Thus, our data support the notion that sex divergence in tail length relative to body length in snakes reflects the action of sexual selection for male mating success.