During weaning, piglets are susceptible to intestinal inflammation and impairment in barrier function. Dietary fiber (DF) plays an active role in alleviating weaning stress in piglets. However, the effects of different sources of dietary fiber on the performance of weaned piglets are inconsistent, and the mechanisms through which they affect intestinal health need to be explored. Therefore, in this study, sixty weaned piglets were randomly divided into three treatment groups: basal diet (control, CON), beet pulp (BP), and alfalfa meal (AM) according to the feed formulation for a 28-day trial. The results showed that both AM and BP groups significantly reduced diarrhea rate and serum inflammatory factors (IL-1β and TNF-α) and increased antioxidant markers (T-AOC and SOD), in addition to decreasing serum MDA and ROS concentrations in the AM group. At the same time, piglets in the AM group showed a significant reduction in serum intestinal permeability indices (LPS and DAO) and a substantial increase in serum immunoglobulin levels (IgA, IgG, and IgM) and expression of intestinal barrier-associated genes (Claudin1, Occludin, ZO-1, and MUC1), which resulted in an improved growth performance. Interestingly, the effect of DF on intestinal inflammation and barrier function can be attributed to its modulation of gut microbes. Fiber-degrading bacteria enriched in the AM group (Christensenellaceae_R-7_group, Pediococcus and Weissella) inhibited the production of TLR4- through the promotion of SCFAs (especially butyrate). MyD88-NF-κB signaling pathway activation reduces intestinal inflammation and repairs intestinal barrier function. In conclusion, it may provide some theoretical support and rationale for AM to alleviate weaning stress and improve early intestinal dysfunction, which may have implications for human infants.