Exhausted CD8+ T (Tex) cells in chronic infections and cancer have limited effector function, high co-expression of inhibitory receptors and extensive transcriptional changes compared with effector (Teff) or memory (Tmem) CD8+ T cells. Tex cells are important clinical targets of checkpoint blockade and other immunotherapies. Epigenetically, Tex cells are a distinct immune subset, with a unique chromatin landscape compared with Teff and Tmem cells. However, the mechanisms that govern the transcriptional and epigenetic development of Tex cells remain unknown. Here we identify the HMG-box transcription factor TOX as a central regulator of Tex cells in mice. TOX is largely dispensable for the formation of Teff and Tmem cells, but it is critical for exhaustion: in the absence of TOX, Tex cells do not form. TOX is induced by calcineurin and NFAT2, and operates in a feed-forward loop in which it becomes calcineurin-independent and sustained in Tex cells. Robust expression of TOX therefore results in commitment to Tex cells by translating persistent stimulation into a distinct Tex cell transcriptional and epigenetic developmental program.