Extensive cellular heterogeneity exists within specific immune-cell subtypes classified as a single lineage, but its molecular underpinnings are rarely characterized at a genomic scale. Here, we use single-cell RNA-seq to investigate the molecular mechanisms governing heterogeneity and pathogenicity of Th17 cells isolated from the central nervous system (CNS) and lymph nodes (LN) at the peak of autoimmune encephalomyelitis (EAE) or differentiated in vitro under either pathogenic or non-pathogenic polarization conditions. Computational analysis relates a spectrum of cellular states in vivo to in-vitro-differentiated Th17 cells and unveils genes governing pathogenicity and disease susceptibility. Using knockout mice, we validate four new genes: Gpr65, Plzp, Toso, and Cd5l (in a companion paper). Cellular heterogeneity thus informs Th17 function in autoimmunity and can identify targets for selective suppression of pathogenic Th17 cells while potentially sparing non-pathogenic tissue-protective ones. VIDEO ABSTRACT.