Immune responses can significantly alter the structure and function of the gut microbiota, leading to rapid transcriptional and metabolic shifts in commensal microbes. However, the host mediators involved in this process and their effects on bacteria remain poorly elucidated. Here, using a flagellin injection model to induce immune activation, we identified unsaturated long-chain fatty acids (uLCFAs) as broad modulators that are released into the gut lumen and alter bacterial gene expression. Luminal release of uLCFAs is partially mediated by host phospholipases, including PLA2G5. In response to uLCFAs, commensals such as Blautia trigger the expression of ohyA, encoding oleate hydratase, which converts toxic uLCFAs to non-toxic hydroxy fatty acids with immunomodulatory properties. Remarkably, oral administration of uLCFAs to mice replicates many of the bacterial transcriptional changes induced by flagellin. This molecular loop underscores the sophisticated interactions between host and microbiota and sheds light on how immune responses affect gut commensal functions.