Bile acids are abundant in the mammalian gut, where they undergo bacteria-mediated transformation to generate a large pool of bioactive molecules. Although bile acids are known to affect host metabolism, cancer progression and innate immunity, it is unknown whether they affect adaptive immune cells such as T helper cells that express IL-17a (TH17 cells) or regulatory T cells (Treg cells). Here we screen a library of bile acid metabolites and identify two distinct derivatives of lithocholic acid (LCA), 3-oxoLCA and isoalloLCA, as T cell regulators in mice. 3-OxoLCA inhibited the differentiation of TH17 cells by directly binding to the key transcription factor retinoid-related orphan receptor-γt (RORγt) and isoalloLCA increased the differentiation of Treg cells through the production of mitochondrial reactive oxygen species (mitoROS), which led to increased expression of FOXP3. The isoalloLCA-mediated enhancement of Treg cell differentiation required an intronic Foxp3 enhancer, the conserved noncoding sequence (CNS) 3; this represents a mode of action distinct from that of previously identified metabolites that increase Treg cell differentiation, which require CNS1. The administration of 3-oxoLCA and isoalloLCA to mice reduced TH17 cell differentiation and increased Treg cell differentiation, respectively, in the intestinal lamina propria. Our data suggest mechanisms through which bile acid metabolites control host immune responses, by directly modulating the balance of TH17 and Treg cells.