R-2-hydroxyglutarate accumulates to millimolar levels in cancer cells with gain-of-function isocitrate dehydrogenase 1/2 mutations. These levels of R-2-hydroxyglutarate affect 2-oxoglutarate-dependent dioxygenases. Both metabolite enantiomers, R- and S-2-hydroxyglutarate, are detectible in healthy individuals, yet their physiological function remains elusive. Here we show that 2-hydroxyglutarate accumulates in mouse CD8+ T cells in response to T-cell receptor triggering, and accumulates to millimolar levels in physiological oxygen conditions through a hypoxia-inducible factor 1-alpha (HIF-1α)-dependent mechanism. S-2-hydroxyglutarate predominates over R-2-hydroxyglutarate in activated T cells, and we demonstrate alterations in markers of CD8+ T-cell differentiation in response to this metabolite. Modulation of histone and DNA demethylation, as well as HIF-1α stability, mediate these effects. S-2-hydroxyglutarate treatment greatly enhances the in vivo proliferation, persistence and anti-tumour capacity of adoptively transferred CD8+ T cells. Thus, S-2-hydroxyglutarate acts as an immunometabolite that links environmental context, through a metabolic-epigenetic axis, to immune fate and function.