Interactions between T cell receptors (TCRs) and their cognate tumour antigens are central to antitumour immune responses1,2,3; however, the relationship between phenotypic characteristics and TCR properties is not well elucidated. Here we show, by linking the antigenic specificity of TCRs and the cellular phenotype of melanoma-infiltrating lymphocytes at single-cell resolution, that tumour specificity shapes the expression state of intratumoural CD8+ T cells. Non-tumour-reactive T cells were enriched for viral specificities and exhibited a non-exhausted memory phenotype, whereas melanoma-reactive lymphocytes predominantly displayed an exhausted state that encompassed diverse levels of differentiation but rarely acquired memory properties. These exhausted phenotypes were observed both among clonotypes specific for public overexpressed melanoma antigens (shared across different tumours) or personal neoantigens (specific for each tumour). The recognition of such tumour antigens was provided by TCRs with avidities inversely related to the abundance of cognate targets in melanoma cells and proportional to the binding affinity of peptide–human leukocyte antigen (HLA) complexes. The persistence of TCR clonotypes in peripheral blood was negatively affected by the level of intratumoural exhaustion, and increased in patients with a poor response to immune checkpoint blockade, consistent with chronic stimulation mediated by residual tumour antigens. By revealing how the quality and quantity of tumour antigens drive the features of T cell responses within the tumour microenvironment, we gain insights into the properties of the anti-melanoma TCR repertoire.