Segmented filamentous bacteria drive the acquisition of the TH17 phenotype in an antigen-specific manner; these findings begin to elucidate how gut-induced TH17 cells can contribute to distal organ-specific autoimmune disease. Colonization of the small intestine by microbes such as segmented filamentous bacteria is known to enhance the induction of T-helper-17 (TH17) cells, which are important factors in both mucosal defence and in autoimmune disease pathogenesis. Here Dan Littman and colleagues demonstrate that the vast majority of TH17 cells in mice colonized with segmented filamentous bacteria are directed at antigens encoded by these bacteria, and identify specific bacterial epitopes that are recognized by TH17 T-cell receptors. This work provides insights into how microbiota communicate with the host immune system, and suggests possible routes for developing novel mucosal vaccines. T-helper-17 (TH17) cells have critical roles in mucosal defence and in autoimmune disease pathogenesis1,2,3. They are most abundant in the small intestine lamina propria, where their presence requires colonization of mice with microbiota4,5,6,7. Segmented filamentous bacteria (SFB) are sufficient to induce TH17 cells and to promote TH17-dependent autoimmune disease in animal models8,9,10,11,12,13,14. However, the specificity of TH17 cells, the mechanism of their induction by distinct bacteria, and the means by which they foster tissue-specific inflammation remain unknown. Here we show that the T-cell antigen receptor (TCR) repertoire of intestinal TH17 cells in SFB-colonized mice has minimal overlap with that of other intestinal CD4+ T cells and that most TH17 cells, but not other T cells, recognize antigens encoded by SFB. T cells with antigen receptors specific for SFB-encoded peptides differentiated into RORγt-expressing TH17 cells, even if SFB-colonized mice also harboured a strong TH1 cell inducer, Listeria monocytogenes, in their intestine. The match of T-cell effector function with antigen specificity is thus determined by the type of bacteria that produce the antigen. These findings have significant implications for understanding how commensal microbiota contribute to organ-specific autoimmunity and for developing novel mucosal vaccines.