Heat stress (HS) has become an inevitable issue in modern livestock industry. It was universally believed that boars exhibit great reproductive susceptibility to HS, thereby prompting research into nutritional interventions for HS mitigation. Rather than conventional nutritional interventions against HS, modern studies have been concentrating on intestinal microecology. This study aimed to evaluate the prebiotic potential of fructooligosaccharides (FOS) on alleviating HS-induced semen quality impairment. The experiment was conducted as 2 × 2 factorial design and completely randomized design. 40 adult Duroc boars randomly assigned to low-fiber thermoneutral (LF-TN; average body weight = 209.8 kg) group, high-fiber thermoneutral (HF-TN; average body weight = 211.78 kg) group, low-fiber HS (LF-HS; average body weight = 209.55 kg) group and high-fiber HS (HF-HS; average body weight = 213.56 kg) group during 13-week experimental period. HF groups received additional 10% FOS, while HS groups were subjected to a 2-week HS challenge at 33 ℃ room temperature (RT) from week 7 to week 8 (W7–W8). Dietary FOS further exacerbated the rise in rectal temperature under HS conditions (PDiet × RT × time < 0.05). It also aggravated the HS-induced semen quality parameter declines, especially for progressive motility at W10, rapid progressive motility at W9 and effective sperm count at W9 (PHF-HS vs LF-HS < 0.05; HF-HS vs LF-HS < 0.05; HF-HS vs LF-HS < 0.05). Based on mediation analysis, rectal temperature had tendencies toward mediating FOS-induced aggravation in progressive motility, rapid progressive motility and effective sperm count (P < 0.10; P < 0.10; P < 0.10;). On the other hand, the microbial-metabolite target metabolomics detected promotion in fecal pyridoxamine concentration when comparing HF-HS with LF-HS, suggesting pyridoxamine may ameliorate concentration, progressive motility and effective sperm count declines after HS exposure (P HF-HS vs LF-HS< 0.01; Ppyridoxamine vs concentration < 0.05; Ppyridoxamine vs progressive motility < 0.05; Ppyridoxamine vs effective sperm count < 0.05). Collectively, Dietary FOS supplement elevated rectal temperature of pigs under HS conditions, resulting in deterioration of semen quality impairment. Nevertheless, FOS exerted beneficial prebiotic effects by elevating fecal pyridoxamine levels, which potentially mitigated semen quality impairment after HS exposure.