The gut microbiota plays an important role in intestinal immune system development and in driving inflammation. Antibiotic administration for therapeutic purposes causes an imbalance in the gut microbiota. Antimicrobial peptides can regulate the gut microbiota and maintain intestinal homeostasis. The aim of this study was to investigate the anti-inflammatory effects and regulation of the gut microbiota by the orally administered antimicrobial peptide mastoparan X (MPX). In this study, Escherichia coli was used to induce intestinal inflammation, and the results showed that MPX+ E. coli alleviated weight loss and intestinal pathological changes in necropsy specimens of E. coli-infected mice. MPX+ E. coli reduced the serum levels of the inflammation-related proteins interleukin-2, interleukin-6, tumour necrosis factor-α, myeloperoxidase, and lactate dehydrogenase on days 7 and 28. Furthermore, MPX+ E. coli increased the length of villi and reduced the infiltration of inflammatory cells into the jejunum and colon post infection. Scanning electron microscopy and transmission electron microscopy results showed that MPX could improve the morphology of jejunum villi and microvilli and increase tight junction protein levels. 16S rRNA sequencing analysis of caecal content samples showed that the species diversity and richness were lower in the E. coli-infected group. At the genus level, MPX+ E. coli significantly reduced the abundance of Bacteroidales and Alistipes and enhanced the relative abundance of Muribaculaceae. Alpha-diversity analyses (Shannon index) showed that MPX significantly increased the microbial diversity of mice. Overall, this study is the first to investigate the effects of oral administration of MPX on intestinal inflammation and the gut microbiota, providing a new perspective regarding the prevention of enteritis and maintenance of intestinal homeostasis.