Angong Niuhuang Pill (ANP) is a famous traditional Chinese patent medicine and is used for treating ischemic or hemorrhagic stroke for centuries. However, the mechanism of action of ANP in stroke treatment has rarely been reported. With increasing evidence for a mechanistic link between acute ischemic stroke and gut microbiota alterations, this study aimed to determine the mechanism of action of ANP in treating acute ischemic stroke from the perspective of the gut microbiota. A mouse model of acute ischemic stroke by middle cerebral artery occlusion (MCAO) was established, and 16S ribosomal RNA (rRNA) gene sequencing and metabolomic analysis were performed on the cecal content samples collected from the sham, model, and ANP-treated MCAO mice. The results showed that ANP significantly ameliorated cerebral infarct volume, improved neurological deficits, and reduced histopathological injuries in the ipsilateral ischemic cortex, hippocampus, and striatum. The latter effects included inhibition of neuronal death, increased Nissl bodies, and decreased cell apoptosis. Moreover, ANP reversed gut microbiota dysbiosis by modulating the abundance of bacteria whose effects may mitigate MCAO damage, such as the phyla Bacteroidetes and Firmicutes, the families Lachnospiraceae and Prevotellaceae, and the genera Alloprevotella and Roseburia. Microbial metabolites related to inflammation and neuroprotection, such as prostaglandin I2 and uridine, were also regulated by ANP treatment. Uridine, guanosine, and inosine might be potential neuromodulators produced by the gut microbiota in the ANP-treated group. Spearman correlation analysis revealed that these metabolites were intimately related to certain genera, including Alloprevotella, Lachnoclostridium, Enterorhabdus, Roseburia, Lachnospiraceae_UCG-006, and Colidextribacter. Our results demonstrated that alleviating gut microbiota dysbiosis is one of the mechanisms by which ANP protects against ischemic stroke and suggest that targeting Alloprevotella, Lachnoclostridium, Enterorhabdus, Roseburia, Lachnospiraceae_UCG-006, and Colidextribacter might be a potential anti-stroke therapy.