The nature and extent of immune cell infiltration into solid tumours are key determinants of therapeutic response. Here, using a DNA methylation-based approach to tumour cell fraction deconvolution, we report the integrated analysis of tumour composition and genomics across a wide spectrum of solid cancers. Initially studying head and neck squamous cell carcinoma, we identify two distinct tumour subgroups: 'immune hot' and 'immune cold', which display differing prognosis, mutation burden, cytokine signalling, cytolytic activity and oncogenic driver events. We demonstrate the existence of such tumour subgroups pan-cancer, link clonal-neoantigen burden to cytotoxic T-lymphocyte infiltration, and show that transcriptional signatures of hot tumours are selectively engaged in immunotherapy responders. We also find that treatment-naive hot tumours are markedly enriched for known immune-resistance genomic alterations, potentially explaining the heterogeneity of immunotherapy response and prognosis seen within this group. Finally, we define a catalogue of mediators of active antitumour immunity, deriving candidate biomarkers and potential targets for precision immunotherapy.