Anisogamy characterizes the difference between the sexes—males produce small sperm and females large eggs. Based on an ecologically grounded model, we conclude that ansiogamy evolved not as a consequence of gametic conflict in the form of "cheater" sperm invading, but as an adaptation to increase gametic contacts. As mortality increases and growth to final size takes longer, individuals are selected to increase the size of gametes of one type. The size and growth rate correlates predicted from this model are tested with data from colonial green algae. Once ansiogamy has evolved in a hermaphroditic population, further selection on individuals to specialize on producing gametes of only one size results in dioecy. We predict for externally fertilizing populations living in an environment of uniform sperm density that neither hermaphrodism nor dioecy have any selective advantage. However, when sperm densities are localized, each hermaphrodite has greater fertility when it is mobile and targets its sperm to specific eggs. Males then do better than hermaphrodites due to the fertility advantage gained by producing twice as much sperm. Hence dioecy is selected because it increases the number of gametic contacts. In immobile species, we find the choice of sexual system depends on the spatial structure of the population and on individuals being self-compatible. Plants overcome the cost of being immobile by investing in pollinators. Whether hermaphrodism or dioecy is favored then depends on the cost of attracting pollinators and the amount of parental care ovule-producers provide. When both these costs are high, dioecy appears to be advantageous, as illustrated by cycads. These models deduce the ecologically adaptive sexual system, thus contributing to social selection theory.