Epigenetic dysregulation is a defining feature of tumorigenesis that is implicated in immune escape1,2. Here, to identify factors that modulate the immune sensitivity of cancer cells, we performed in vivo CRISPR–Cas9 screens targeting 936 chromatin regulators in mouse tumour models treated with immune checkpoint blockade. We identified the H3K9 methyltransferase SETDB1 and other members of the HUSH and KAP1 complexes as mediators of immune escape3,4,5. We also found that amplification of SETDB1 (1q21.3) in human tumours is associated with immune exclusion and resistance to immune checkpoint blockade. SETDB1 represses broad domains, primarily within the open genome compartment. These domains are enriched for transposable elements (TEs) and immune clusters associated with segmental duplication events, a central mechanism of genome evolution6. SETDB1 loss derepresses latent TE-derived regulatory elements, immunostimulatory genes, and TE-encoded retroviral antigens in these regions, and triggers TE-specific cytotoxic T cell responses in vivo. Our study establishes SETDB1 as an epigenetic checkpoint that suppresses tumour-intrinsic immunogenicity, and thus represents a candidate target for immunotherapy.