Objective To investigate the effects of the Qingre Huatan Tongfu Prescription (HTF) on gastrointestinal motility and intestinal flora in rat model with stroke⁃associated pneumonia (SAP). Methods Twenty⁃four SPF⁃grade male SD rats were randomly divided into sham⁃operation group, SAP model group, HTF enema treatment group, or normal saline enema treatment group, with 6 rats in each group. Except for the sham⁃operation group, SAP rat models were established in the remaining three groups using the modified filament embolization method combined with tracheal injection of Pseudomonas aeruginosa. The sham⁃operation group underwent the same surgical procedures only. Six hours after modeling, the HTF enema treatment group and the normal saline enema treatment group received enema with HTF medicinal liquid or normal saline enemas respectively, while the sham⁃operation group and SAP model group received no enema. Interventions were administered for 7 consecutive days. The general state of the rats in each group was observed. Neurological deficit scores and Bristol stool form scores were assessed. Gastric emptying rate and small intestinal propulsion rate were evaluated. Serum levels of gastrin and motilin were detected using ELISA. The bacterial flora of the contents of appendix was detected using 16S rDNA high⁃throughput sequencing technology. Brain tissue was stained with TTC, and HE staining was performed on brain, lung, and colon tissues. Lung tissue homogenate was cultured for Pseudomonas aeruginosa. Results Rats in the SAP model group exhibited rapid breathing, sneezing, and a large amount of nasal secretions, while rats in the HTF enema treatment group had unsteady breathing and a small amount of nasal secretions. Seven days after modeling, compared with the SAP model group, the HTF enema treatment group exhibited reduced neurological deficit scores, increased Bristol stool form scores, gastric emptying rate, and small intestinal propulsion rate, but the differences were not statistically significant (P>0.05). Serum levels of motilin and gastrin were increased, and the cerebral infarction volume was reduced (P<0.05). Compared with the SAP model group, the Shannon index of the bacterial flora of the contents of appendix decreased in the HTF enema treatment group (P<0.05), while the Simpson index, Chao1 index, and ACE index also decreased, but the differences were not statistically significant (P>0.05). Compared with the SAP model group, the relative abundances of Desulfovibrionaceae and Porphyromonadaceae in the bacterial flora of the contents of appendix decreased in the HTF enema treatment group, while the relative abundances of Enterobacteriaceae, Lachnospiraceae, and Prevotellaceae increased. Except for the normal saline enema treatment group, the remaining three groups had significantly different species. Pseudomonas aeruginosa colonies were cultured from both the SAP model group and the HTF enema treatment group, and the colony count was lower in the HTF enema treatment group compared to the SAP model group. Pathological inflammatory damage in the brain, lung, and colon tissues of rats in the HTF enema treatment group was alleviated compared to the SAP model group. Conclusion HTF can effectively improve gastrointestinal motility in SAP rats, alter the abundance and diversity of intestinal species, improve neurological deficits, and demonstrate significant therapeutic effects on SAP.