Complex interactions between the host and the gut microbiota govern intestinal homeostasis but remain poorly understood. Here we reveal a relationship between gut microbiota and caspase recruitment domain family member 9 (CARD9), a susceptibility gene for inflammatory bowel disease (IBD) that functions in the immune response against microorganisms. CARD9 promotes recovery from colitis by promoting interleukin (IL)-22 production, and Card9(-/-) mice are more susceptible to colitis. The microbiota is altered in Card9(-/-) mice, and transfer of the microbiota from Card9(-/-) to wild-type, germ-free recipients increases their susceptibility to colitis. The microbiota from Card9(-/-) mice fails to metabolize tryptophan into metabolites that act as aryl hydrocarbon receptor (AHR) ligands. Intestinal inflammation is attenuated after inoculation of mice with three Lactobacillus strains capable of metabolizing tryptophan or by treatment with an AHR agonist. Reduced production of AHR ligands is also observed in the microbiota from individuals with IBD, particularly in those with CARD9 risk alleles associated with IBD. Our findings reveal that host genes affect the composition and function of the gut microbiota, altering the production of microbial metabolites and intestinal inflammation.