The nematode Caenorhabditis elegans counts its X chromosomes to determine sex and to activate the process of dosage compensation, which ensures that males (XO) and hermaphrodites (XX) express equal levels of most X-chromosome products. The number of X chromosomes is communicated by a set of X-linked genes called X-signal elements, which repress the master sex-determination switch gene xol-1 via two distinct, dose-dependent molecular mechanisms in XX embryos. X-chromosome gene dosage is compensated by a specialized protein complex that includes evolutionarily conserved components of mitotic and meiotic machinery. This complex assembles on both X chromosomes of hermaphrodites to repress transcription by half. The recruitment of chromosome segregation proteins to the new task of regulating X-chromosome-wide gene expression points to the evolutionary origin of nematode dosage compensation.