The amino acid sequence of mammalian DNA methyltransferase has been deduced from the nucleotide sequence of a cloned cDNA. It appears that the mammalian enzyme arose during evolution via fusion of a prokaryotic restriction methyltransferase gene and a second gene of unknown function. Mammalian DNA methyltransferase currently comprises an N-terminal domain of about 1000 amino acids that may have a regulatory role and a C-terminal 570 amino acid domain that retains similarities to bacterial restriction methyltransferases. The sequence similarities among mammalian and bacterial DNA cytosine methyltransferases suggest a common evolutionary origin. DNA methylation is uncommon among those eukaryotes having genomes of less than 10<latex>$^8$</latex> base pairs, but nearly universal among large-genome eukaryotes. This and other considerations make it likely that sequence inactivation by DNA methylation has evolved to compensate for the expansion of the genome that has accompanied the development of higher plants and animals. As methylated sequences are usually propagated in the repressed, nuclease-insensitive state, it is likely that DNA methylation compartmentalizes the genome to facilitate gene regulation by reducing the total amount of DNA sequence that must be scanned by DNA-binding regulatory proteins. DNA methylation is involved in immune recognition in bacteria but appears to regulate the structure and expression of the genome in complex higher eukaryotes. I suggest that the DNA-methylating system of mammals was derived from that of bacteria by way of a hypothetical intermediate that carried out selective de novo methylation of exogenous DNA and propagated the methylated DNA in the repressed state within its own genome. During the evolution of complex plants and animals the inactivating effects of DNA methylation spread to extraneous cellular sequences, such as highly repetitive DNA and transposable elements, and later to tissue-specific genes. Modern large-genome eukaryotes have adapted a primitive prokaryotic immune system to enable them to manage a genome that has expanded more than 1000-fold as a result of accumulation of extraneous sequences and tissue-specific genes.