The RNA modification N6-methyladenosine (m6A) has critical roles in many biological processes1,2. However, the function of m6A in the early phase of mammalian development remains poorly understood. Here we show that the m6A reader YT521-B homology-domain-containing protein 1 (YTHDC1) is required for the maintenance of mouse embryonic stem (ES) cells in an m6A-dependent manner, and that its deletion initiates cellular reprogramming to a 2C-like state. Mechanistically, YTHDC1 binds to the transcripts of retrotransposons (such as intracisternal A particles, ERVK and LINE1) in mouse ES cells and its depletion results in the reactivation of these silenced retrotransposons, accompanied by a global decrease in SETDB1-mediated trimethylation at lysine 9 of histone H3 (H3K9me3). We further demonstrate that YTHDC1 and its target m6A RNAs act upstream of SETDB1 to repress retrotransposons and Dux, the master inducer of the two-cell stage (2C)-like program. This study reveals an essential role for m6A RNA and YTHDC1 in chromatin modification and retrotransposon repression.