Most metazoans occur as two sexes. Surprisingly, molecular analyses have hitherto indicated that sex-determining mechanisms differ completely between phyla. Here we present evidence to the contrary. We have isolated the male sexual regulatory gene mab-3 from the nematode Caenorhabditis elegans and found that it is related to the Drosophila melanogaster sexual regulatory gene doublesex (dsx)2. Both genes encode proteins with a DNA-binding motif that we have named the 'DM domain'. Both genes control sex-specific neuroblast differentiation and yolk protein gene transcription; dsx controls other sexually dimorphic features as well. The form of DSX that is found in males can direct male-specific neuroblast differentiation in C. elegans. This structural and functional similarity between phyla suggests a common evolutionary origin of at least some aspects of sexual regulation. We have identified a human gene, DMT1, that encodes a protein with a DM domain and find that DMT1 is expressed only in testis. DMT1 maps to the distal short arm of chromosome 9, a location implicated in human XY sex reversal. Proteins with DM domains may therefore also regulate sexual development in mammals.