Enterococcus faecium HDRsEf1 (HDRsEf1) was identified to reduce the incidence of diarrhea in weaned piglets, but the mechanism has not been elucidated yet. Based on the fact that gut microbiota plays a crucial role in regulating inflammatory responses, the effects of HDRsEf1 on microbiota across the intestinal tract in weaned piglets were investigated. Microbiota from the luminal contents and the mucosa of the ileum, cecum, and colon of HDRsEf1-treated piglets were explored by 16S rRNA sequencing and qPCR. It was demonstrated that microbiota in different gut niches responded specifically to HDRsEf1, with major alterations occurring in the ileum and cecum. The total bacterial load of microbiota in ileal luminal contents and the relative abundance of Escherichia-Shigella in the ileal mucosa was significantly down-regulated by HDRsEf1 administration, while the relative abundance of butyrate-producing bacteria (including Clostridiaceae-1, Rumencoccidae, and Erysipelotrichaceae) in cecal luminal contents was significantly up-regulated. Moreover, the utilization of HDRsEf1 improved intestinal morphological development and reduced the inflammatory response, which were negatively correlated with the relative abundance of Escherichia-Shigella in the ileal mucosa and butyrate-producing bacteria in cecal luminal contents, respectively. Collectively, this study suggests that the administration of HDRsEf1 alters gut microbiota, thereby alleviating inflammation and improving intestinal morphological development in weaned piglets.