Persistent viral infections are characterized by the simultaneous presence of chronic inflammation and T cell dysfunction. In prototypic models of chronicity—infection with human immunodeficiency virus (HIV) or lymphocytic choriomeningitis virus (LCMV)—we used transcriptome-based modeling to reveal that CD4+ T cells were co-exposed not only to multiple inhibitory signals but also to tumor-necrosis factor (TNF). Blockade of TNF during chronic infection with LCMV abrogated the inhibitory gene-expression signature in CD4+ T cells, including reduced expression of the inhibitory receptor PD-1, and reconstituted virus-specific immunity, which led to control of infection. Preventing signaling via the TNF receptor selectively in T cells sufficed to induce these effects. Targeted immunological interventions to disrupt the TNF-mediated link between chronic inflammation and T cell dysfunction might therefore lead to therapies to overcome persistent viral infection.