Aurantii Fructus Immaturus (AFI), a traditional Qi-regulating Chinese medicine, is commonly utilized in clinical prescriptions to treat diverse gastrointestinal diseases. Recent studies have demonstrated that the flavonoids in AFI effectively enhance gastrointestinal motility. But the effects of other active components in AFI on gastrointestinal motility remain unclear. Meanwhile, numerous studies have found that gastrointestinal motility is closely related to gut microbiota. To explore the effects improving gastrointestinal motility and influences on gut microbiota of Aurantii Fructus Immaturus extract and its ingredient stachydrine, the mice with gastrointestinal motility disorder (GIMD) induced by loperamide hydrochloride were orally treated with AFI extract, its fraction and stachydrine for three weeks. After the treatment, the therapeutic effects of AFI extract, its fraction and stachydrine were evaluated by measuring gastrointestinal motility related indexes including gastrointestinal transit time, gastric emptying and small intestine propulsion rate. Simultaneously, the effects of AFI extract, its fraction and stachydrine on gut microbiota were evaluated by 16S rRNA gene sequencing. Short-chain fatty acids (SCFAs) and bile acids (BAs), two gut microbial metabolites, were quantitatively analysed using gas chromatography (GC) and high-performance liquid chromatography tandem mass spectrometry (HPLC-MS). The correlation between gastrointestinal motility indexes, differential gut microbiota, and their metabolites was investigated using Spearman analysis. The results showed that AFI extract, its fraction and stachydrine improved the physiological state of the mice and exhibited significant improvement in gastrointestinal motility. Moreover, AFI extract, its fraction and stachydrine treatment reshaped the composition of gut microbiota by reducing pro-inflammatory bacteria and increasing bacteria that produce SCFAs in GIMD mice. In addition, AFI extract, its fraction and stachydrine regulated the levels of gut microbial metabolites, including SCFAs and BAs that participate in regulating gastrointestinal motility. The Spearman's correlation indicated a certain association between gastrointestinal motility indexes, gut microbiota and their metabolites. Therefore, AFI extract and its fraction can significantly improve gastrointestinal motility, suggesting that other active components are improving gastrointestinal motility besides flavonoids in AFI. Furthermore, stachydrine is a new bioactive ingredient of AFI extract improving gastrointestinal motility. AFI extract, its fraction and stachydrine may indirectly improve gastrointestinal motility by altering the composition and metabolism of gut microbiota to restore gastrointestinal function. This study establishes scientific evidence for the mechanism of AFI in treating GIMD.