BACKGROUND: The response of the microbiota to weaning plays a crucial role in shaping long-term immunity and overall lifelong health. The gut and milk microbiota of mothers exert a profound influence on the microbiota and health of their offspring. Although Shenling Baizhu powder (SBP) has demonstrated efficacy in alleviating weaning stress-induced diarrhea in suckling piglets, the underlying mechanism of this effect remains unknown. METHODS: One hundred sows were randomly assigned to two groups: the control (CON) group and the SBP group. Piglet body weights were recorded after birth and at weaning day. Colostrum was collected at 2-12 h after delivery for subsequent SIgA determination via ELISA. Sow feces, piglet feces and colostrum were collected for 16S rRNA gene sequence analysis. Sixteen SD rats were randomly assigned to four groups. Milk pills were collected from the stomach of newborn rats and EGF, TGFβ2 and SIgA were subsequently determined via ELISA. Maternal and neonatal rat feces and milk were collected on the weaning day for 16S rRNA gene sequence analysis. Ileum and colon tissues were collected for subsequent detection via RT‒qPCR. RESULTS: We observed that supplementing with SBP during pregnancy and lactation enhanced the weaning weights of the piglets. This effect was associated with an improvement in the microbiota structure, particularly in the promotion of short-chain fatty acid (SCFA)-producing bacteria in the maternal gut, milk and neonatal gut. Furthermore, SBP treatment increased the similarity of the microbiota among these maternal and neonatal components. These findings were replicated in rats. Additionally, SBP led to an increase in SCFA production in the milk of maternal rats. Moreover, SBP upregulated G protein-coupled receptors (GPCRs) expression, resulting in enhanced expression of the tight junction proteins ZO-1 and Occludin. Also, SBP treatment significantly elevated the levels of transforming growth factor beta 2 (TGFβ2), epidermal growth factor (EGF), and secretory immunoglobulin A (SIgA) in the milk. CONCLUSIONS: Our findings indicate that SBP mediates beneficial effects by facilitating the transmission of maternal microbiota to neonates through milk, thereby promoting intestinal health and alleviating weaning stress in neonates.