Angiosperms range in sexual system from hermaphroditism through gynodioecy and androdioecy to dioecy. Trioecy, where females and males coexist with hermaphrodites, is rare. Recently, trioecy was documented in hexaploid populations of the wind-pollinated herb Mercurialis annua in Spain. We surveyed the frequency of males, hermaphrodites, and females in M. annua across its distribution in the Iberian Peninsula, tracked sex-ratio variation in several populations over consecutive generations, and assessed evidence for pollen limitation. In a common garden, we estimated male, female, and hermaphroditic fitness. We used controlled crosses to infer the genetic basis of male sterility. Finally, we compared predictions of a deterministic model with the distribution of observed sex ratios in the field based on our fitness estimates and the inferred genetics of sex determination. Trioecy is widespread in Spanish and Portuguese populations of M. annua. Males are determined by a dominant (Y-linked) allele, and female expression results from the interaction between cytoplasmic male sterility and multiple nuclear male sterility restorers partially linked to the male determiner. Male pollen production is approximately 12 times that of hermaphrodites, while female seed production is less than 1.12 times the observed hermaphroditic levels. The distribution of sex ratios in natural populations conforms with predictions of our deterministic simulations. Our study documents and accounts for a clear case of trioecy in which sex is determined by both maternally and biparentally inherited genes.