Dioecy, the separation of sexes, has arisen independently many times in the course of angiosperm evolution. Avoidance of inbreeding is clearly involved in the evolution of dioecy, and as a consequence we predict that dioecious populations should maintain higher levels of genetic variation than closely related nondioecious populations. We tested that prediction by comparing allozymic variation in two closely related taxa, the monoecious and dioecious subspecies of the Mediterranean cucurbit, Ecballium elaterium. Thirteen polymorphic loci were screened for seeds sampled from 10 monoecious and 13 dioecious populations spanning the geographic ranges of the subspecies in Spain. The dioecious subspecies showed strikingly greater allelic diversity and heterozygosity than the monoecious subspecies. A hierarchical F-statistic analysis clearly demonstrated considerable genetic variation within populations for the dioecious populations, whereas for the monoecious populations almost all genetic variation resulted from differences among populations. The general pattern of homozygosity within monoecious populations suggests that they are highly inbred. In order to assess historical influences on current patterns of genetic variation, we conducted a genetic-distance analysis. The observed relationship between genetic distance and geographic distance between populations supports the hypothesis that the subspecies' current allopatric distributions on the Iberian Peninsula are the result of separate waves of colonization from the north (monoecious) and south (dioecious).