Intestinal microbes provide multicellular hosts with nutrients and confer resistance to infection. The delicate balance between pro- and anti-inflammatory mechanisms, essential for gut immune homeostasis, is affected by the composition of the commensal microbial community. Regulatory T cells (Treg cells) expressing transcription factor Foxp3 have a key role in limiting inflammatory responses in the intestine. Although specific members of the commensal microbial community have been found to potentiate the generation of anti-inflammatory Treg or pro-inflammatory T helper 17 (TH17) cells, the molecular cues driving this process remain elusive. Considering the vital metabolic function afforded by commensal microorganisms, we reasoned that their metabolic by-products are sensed by cells of the immune system and affect the balance between pro- and anti-inflammatory cells. We tested this hypothesis by exploring the effect of microbial metabolites on the generation of anti-inflammatory Treg cells. We found that in mice a short-chain fatty acid (SCFA), butyrate, produced by commensal microorganisms during starch fermentation, facilitated extrathymic generation of Treg cells. A boost in Treg-cell numbers after provision of butyrate was due to potentiation of extrathymic differentiation of Treg cells, as the observed phenomenon was dependent on intronic enhancer CNS1 (conserved non-coding sequence 1), essential for extrathymic but dispensable for thymic Treg-cell differentiation. In addition to butyrate, de novo Treg-cell generation in the periphery was potentiated by propionate, another SCFA of microbial origin capable of histone deacetylase (HDAC) inhibition, but not acetate, which lacks this HDAC-inhibitory activity. Our results suggest that bacterial metabolites mediate communication between the commensal microbiota and the immune system, affecting the balance between pro- and anti-inflammatory mechanisms.