Why are there two sexes in certain species, instead of one hermaphroditic sex? Why are Y chromosomes shorter than X chromosomes, but only in certain lineages? I propose that differences between sexes are initially determined by differential methylation in nuclear DNA between females and males, driving Muller's ratchet. Methylation of promoters suppresses transcription, including loci coding for gamete production, thereby converting hermaphroditic individuals into females or males. Differential methylation of sex chromosomes suppresses recombination and increases mutation rate, thereby geometrically increasing the speed of Muller's ratchet. Higher mutability of methylated nucleotides plus loss of sex-determining function of previously methylated nucleotides provides selective pressure to excise these loci, resulting in shorter Y or W chromosomes. Derived lineages usually have more methylation than do ancestral ones, and hence have relatively shorter sex chromosomes. Methylation canalizes dioecy and degeneration of sex chromosomes. Latter stages of sex chromosome evolution may have occurred via other mechanisms, for example sexually antagonistic genes or chromosomal rearrangements. A few aberrant derived lineages lost most methylation, and their sex determination and sex chromosomes may have evolved via other means. Differential methylation provides a mechanism for early evolution of dioecy in anisogamous sexual diploid eukaryotes and of sex chromosomes in metazoans. © 2003 The Linnean Society of London, Biological Journal of the Linnean Society, 2003, 80, 353–368.