The syndrome of dampness stagnancy due to spleen deficiency (DSSD) is relatively common globally. Although the pathogenesis of DSSD remains unclear, evidence has suggested that the gut microbiota might play a significant role. Radix Astragali, used as both medicine and food, exerts the effects of tonifying spleen and qi. Astragalus polysaccharide (APS) comprises a macromolecule substance extracted from the dried root of Radix Astragali, which has many pharmacological functions. However, whether APS mitigates the immune disorders underlying the DSSD syndrome via regulating gut microbiota and the relevant mechanism remains unknown. Here, we used DSSD rats induced by high-fat and low-protein (HFLP) diet plus exhaustive swimming, and found that APS of moderate molecular weight increased the body weight gain and immune organ indexes, decreased the levels of interleukin-1β (IL-1β), IL-6, and endotoxin, and suppressed the Toll-like receptor 4/nuclear factor-κB (TLR4/NF-κB) pathway. Moreover, a total of 27 critical genera were significantly enriched according to the linear discriminant analysis effect size (LEfSe). APS increased the diversity of the gut microbiota and changed its composition, such as reducing the relative abundance of Pseudoflavonifractor and Paraprevotella, and increasing that of Parasutterella, Parabacteroides, Clostridium XIVb, Oscillibacter, Butyricicoccus, and Dorea. APS also elevated the contents of short-chain fatty acids (SCFAs). Furthermore, the correlation analysis indicated that 12 critical bacteria were related to the body weight gain and immune organ indexes. In general, our study demonstrated that APS ameliorated the immune disorders in DSSD rats via modulating their gut microbiota, especially for some bacteria involving immune and inflammatory response and SCFA production, as well as the TLR4/NF-κB pathway. This study provides an insight into the function of APS as a unique potential prebiotic through exerting systemic activities in treating DSSD.