BACKGROUNDHeat stress (HS) damages the intestines, disrupting gut microbiota and immune balance. l‐Theanine (LTA), found in tea, alleviates oxidative stress and cell apoptosis under HS; however, its effects on gut microbiota and immunity under HS remain unclear. To investigate this, we administered LTA doses of 100, 200, and 400 mg·kg−1·d−1 to C57BL/6J mice. On day 44, the model group and LTA intervention group were subjected to continuous 7‐day HS treatment for 2 h per day.RESULTSThe results demonstrated that LTA intervention improved food intake, body weight, and intestinal epithelium, and reduced the water intake of heat‐stressed mice. It increased the abundance of Turicibacter, Faecalibaculum, Bifidobacterium, and norank_f_Muribaculaceae, while reducing that of Lachnoclostridium and Desulfovibrio. LTA intervention also increased the concentrations of amino acid and lipid metabolites, regulated macrophage differentiation stimulated by gut microbiota and metabolites, reduced the antigen presentation by macrophages to the specific immune system, promoted B‐cell differentiation and sIgA secretion, inhibited pro‐inflammatory factors, and enhanced intestinal defense. Mechanistically, LTA downregulated heat shock protein 70 expression and the TLR4/NF‐κB/p38 MAPK signaling pathway, restoring gut microbiota and immune balance.CONCLUSIONWe suggest that LTA can alleviate HS by modulating gut microbiota, metabolites, and immunity, indicating its potential as a natural active ingredient for anti‐HS food products. © 2023 Society of Chemical Industry.