Post-weaning diarrhea caused by enterotoxigenic E. coli (ETEC) causes significant economic losses for pig producers. This study was to test the hypotheses that an ETEC challenge disrupts intestinal microbial homeostasis and the inclusion of dietary soluble (10% sugar beet pulp) or insoluble fiber (15% corn distillers dried grains with solubles) with or without exogenous carbohydrases will protect or restore the gut microbial homeostasis in weaned pigs. Sixty crossbred piglets (6.9 ± 0.1 kg) were blocked by body weight and randomly assigned to one of six treatments ( n = 10), including a non-challenged control (NC), ETEC F18-challenged positive control (PC), ETEC-challenged soluble fiber without (SF-) or with carbohydrases (SF+), and ETEC-challenged insoluble fiber without (IF-) or with carbohydrases (IF+). Pigs were housed individually and orally received either ETEC inoculum or PBS-sham inoculum on day 7 post-weaning. Intestinal contents were collected on day 14 or 15. The V4 region of the bacterial 16S rRNA was amplified and sequenced. High-quality reads (total 6,671,739) were selected and clustered into 3,330 OTUs. No differences were observed in α-diversity among treatments. The ileal microbiota in NC and PC had modest separation in the weighted PCoA plot; the microbial structures were slightly altered by SF+ and IF- compared with PC. The PC increased ileal Escherichia-Shigella ( P < 0.01) and numerically decreased Lactobacillus compared to NC. Predicted functional pathways enriched in the ileal microbiota of PC pigs indicated enhanced activity of Gram-negative bacteria, in agreement with increased Escherichia-Shigella . The SF+ tended to decrease ( P < 0.10) ileal Escherichia-Shigella compared to PC. Greater abundance of ileal Streptococcus , Turicibacter , and Roseburia and colonic Prevotella were observed in SF- and SF+ than PC ( P < 0.05). Pigs fed IF + had greater Lactobacillus and Roseburia than PC pigs ( P < 0.05). The ETEC challenge reduced total volatile fatty acid (VFA) compared with NC ( P < 0.05). The SF+ tended to increase ( P < 0.10) and SF- significantly increased ( P < 0.05) colonic total VFA compared with PC. Collectively, ETEC challenge disrupted gut microbial homeostasis and impaired microbial fermentation capacity. Soluble fiber improved VFA production. Dietary fiber and carbohydrases altered microbiota composition to maintain or restore microbial homeostasis.