•Establishment of DNA methylation is guided by the RNA interference pathway. •DNA methylation is maintained by three interconnected pathways. •Several pathways protect genes from the deleterious effects of DNA methylation. •DNA demethylation and RNA-directed DNA methylation regulate gene expression. Transposons are selfish genetic sequences that can increase their copy number and inflict substantial damage on their hosts. To combat these genomic parasites, plants have evolved multiple pathways to identify and silence transposons by methylating their DNA. Plants have also evolved mechanisms to limit the collateral damage from the antitransposon machinery. In this review, we examine recent developments that have elucidated many of the molecular workings of these pathways. We also highlight the evidence that the methylation and demethylation pathways interact, indicating that plants have a highly sophisticated, integrated system of transposon defense that has an important role in the regulation of gene expression. Transposons are selfish genetic sequences that can increase their copy number and inflict substantial damage on their hosts. To combat these genomic parasites, plants have evolved multiple pathways to identify and silence transposons by methylating their DNA. Plants have also evolved mechanisms to limit the collateral damage from the antitransposon machinery. In this review, we examine recent developments that have elucidated many of the molecular workings of these pathways. We also highlight the evidence that the methylation and demethylation pathways interact, indicating that plants have a highly sophisticated, integrated system of transposon defense that has an important role in the regulation of gene expression.