The purpose of this study was to evaluate the effects of different levels of potassium magnesium sulfateon (PMS) on growth performance, diarrhea rate, intestinal morphology, antioxidant capacity, intestinal immunity, and gut microbiota in weaned piglets. A total of 216 weaned piglets were randomly divided into six dietary groups: the basal diet with 0% (CON), 0.15, 0.3, 0.45, 0.6, and 0.75% PMS. The results showed that the ADFI of 29–42 days and 1–42 days was linearly and quadratically increased by the PMS supplementation (P < 0.05), and significantly reduced the diarrhea rate in weaned piglets (P < 0.05). Moreover, dietary supplementation with PMS significantly reduced the serum adrenaline and noradrenaline levels in weaned piglets (P < 0.05). Furthermore, 0.3% PMS significantly increased the activity of glutathione peroxidase (GSH-Px) in the jejunum (P < 0.05) and tended to increase the activity of superoxide dismutase (SOD) in the jejunal mucosa of piglets (P < 0.1). Additionally, dietary supplementation with PMS significantly reduced the interleukin-1β (IL-1β) level in the jejunal mucosa (P < 0.05), and 0.3% PMS increased the serum IgM content in piglets (P < 0.05). Furthermore, the analysis of colonic microbiota by 16S RNA sequencing showed that the addition of PMS increased the Shannon index (P < 0.05) and Observed Species index (P < 0.05). Based on linear discriminant analysis effect size (LEfSe) and T-test analysis, the addition of PMS increased the relative abundance of Ruminococcaceae and Peptostreptococcaceae in the colonic digesta (P < 0.05). Spearman analysis showed that there was a positive correlation between intestinal GSH-Px activity and the relative abundance of Peptostreptococcaceae. These results showed that dietary supplementation with PMS could improve growth performance, alleviate diarrhea incidence, and modulate the antioxidant capacity and intestinal immunity in weaned piglets, which was partially related to the significant changes in colonic microbiota composition.