Progenitor-like CD8+ T cells mediate long-term immunity to chronic infection and cancer and respond potently to immune checkpoint blockade. These cells share transcriptional regulators with memory precursor cells, including T cell-specific transcription factor 1 (TCF1), but it is unclear whether they adopt distinct programs to adapt to the immunosuppressive environment. By comparing the single-cell transcriptomes and epigenetic profiles of CD8+ T cells responding to acute and chronic viral infections, we found that progenitor-like CD8+ T cells became distinct from memory precursor cells before the peak of the T cell response. We discovered a coexpression gene module containing Tox that exhibited higher transcriptional activity associated with more abundant active histone marks in progenitor-like cells than memory precursor cells. Moreover, thymocyte selection-associated high mobility group box protein TOX (TOX) promoted the persistence of antiviral CD8+ T cells and was required for the programming of progenitor-like CD8+ T cells. Thus, long-term CD8+ T cell immunity to chronic viral infection requires unique transcriptional and epigenetic programs associated with the transcription factor TOX.