The diversity and dysregulation of intestinal microbiota is related to the pathology of epilepsy. Gut microbiota plays an important role in epilepsy, and regulating intestinal microbiota through exogenous intervention can alleviate symptoms. However, there are no studies about the effects of epilepsy-related diarrhea on gut microbiota. The diversity and dysregulation of intestinal microbiota is related to the pathology of epilepsy. Gut microbiota plays an important role in epilepsy, and regulating intestinal microbiota through exogenous intervention can alleviate symptoms. However, there are no studies about the effects of epilepsy-related diarrhea on gut microbiota. To evaluate changes in gut microbiota structure and composition in patients with epilepsy and associated diarrhea, the structure and composition of the fecal microbiota among patients with epilepsy (EP, 13 cases), epilepsy with diarrhea (ED, 13 cases), and probiotic treatments (PT, 13 cases), and healthy controls (CK, seven cases) were investigated and validated by utilizing high-throughput 16S rRNA sequencing. The results showed that the α-diversity indexes indicated that richness and phylogenetic diversity had no significant differences among groups. However, the variation of β-diversity indicated that the structure and composition of intestinal microbiota were significantly different among the CK, EP, ED, and PT groups (permutational multivariate analysis of variance, p-value = 0.001). Normalized stochasticity ratio and β-nearest taxon index indicated that stochastic mechanisms exerted increasing influence on community differences with epilepsy and associated diarrhea. ED microbiome alterations include increased Proteobacteria and decreased Actinobacteria and Firmicutes at the phylum level. Bifidobacterium was the core microbe in CK, EP, and PT, whereas it decreased significantly in ED. In contrast, Escherichia/Shigella was the core microbe in CK and ED, whereas it increased significantly in ED (Tukey's multiple comparisons test, adjusted p-value <0.05). The association network in CK has higher complexity and aggregation than in the other groups. The EP network indicated high connectivity density within each community and high sparsity among communities. The bacterial community network of the ED had a more compact local interconnection, which was in contrast to that of PT. The top 7 microbial amplicon sequence variant-based markers that were selected by machine learning to distinguish the groups of epilepsy, probiotic treatments, and healthy infants had stronger discrimination ability. In addition, ASVs_1 (Escherichia/Shigella) and ASVs_3 (Bifidobacterium) had the most importance in the recognition. Our research finally showed that infants with epilepsy, epilepsy with diarrhea, and probiotic treatments exhibit substantial alterations of intestinal microbiota structure and composition, and specific intestinal strains are altered according to different clinical phenotypes and can therefore be used as potential biomarkers for disease diagnosis.