Gut microbiota is closely related to human health and disease because, together with their metabolites, gut microbiota maintain normal intestinal peristalsis. The use of antibiotics or opioid anesthetics, or both, during surgical procedures can lead to dysbiosis and affect intestinal motility; however, the underlying mechanisms are not fully known. This review aims to discuss the effect of gut microbiota and their metabolites on postoperative intestinal motility, focusing on regulating the enteric nervous system, 5-hydroxytryptamine neurotransmitter, and aryl hydrocarbon receptor.