In all domains of life, genomes contain epigenetic information superimposed over the nucleotide sequence. Epigenetic signals control DNA–protein interactions and can cause phenotypic change in the absence of mutation. A nearly universal mechanism of epigenetic signalling is DNA methylation. In bacteria, DNA methylation has roles in genome defence, chromosome replication and segregation, nucleoid organization, cell cycle control, DNA repair and regulation of transcription. In many bacterial species, DNA methylation controls reversible switching (phase variation) of gene expression, a phenomenon that generates phenotypic cell variants. The formation of epigenetic lineages enables the adaptation of bacterial populations to harsh or changing environments and modulates the interaction of pathogens with their eukaryotic hosts. DNA methylation affects DNA–protein interactions and has important cellular roles, including the control of reversible switching (phase variation) of gene expression. In this Review, Sanchez-Romero and Casadesus review epigenetic signalling by DNA methylation, focusing on its contribution to phenotypic heterogeneity in bacterial populations.