Although the influence of population structure on evolution has been explored previously in a variety of theoretical studies, there are few examples of specific traits whose fitness is likely to be modified by the local structure. Here we focus on a specific trait, sex expression in gynodioecious plants, and derive a model in which the fitness of females and hermaphrodites is a function of the local sex ratio. By using the concept d genes. As a consequence, when local demes vary in sex ratio, a polymorphism for a cytoplasmic male sterility (CMS) allele can be maintained in the absence of nuclear alleles that restore male function. When of subjective frequencies, it is shown that among-deme variance in the local sex ratio reduces the average fitness of females when pollen availability limits fertility. In contrast, sex ratio variance increases the fitness of hermaphrodites from the perspective of maternally inherited genes and lessens the negative impact of pollen limitation on hermaphrodite fitness when it is measured from the perspective of biparentally inheriterestorer alleles are introduced into the model, polymorphism cannot be maintained simultaneously at both the cytoplasmic and nuclear loci. In that case, the CMS allele spreads to fixation, and the equilibrium frequency of females is an inverse function of the equilibrium frequency of the restorer allele, which increases with increased structure. The results exemplify how population structure can greatly alter the fitness and evolution of a frequency-dependent trait.