Objective This study aimed to investigate the impact of electroacupuncture (EA) on blood glucose levels, gut microbiota, short-chain fatty acids (SCFAs), and glucagon-like peptide-1 (GLP-1) in a rat model of type 2 diabetes mellitus (T2DM). Methods Forty Sprague–Dawley (SD) rats were randomly assigned to five groups (n = 8/group) using a random number table: normal control, T2DM model, electroacupuncture (EA), EA + antibiotics (EA + A), and antibiotics (A). The normal rats received a standard diet and saline gavage, while the other groups were fed a high-fat diet and emulsion. The EA + A and A groups received additional antibiotic solution gavage. The normal, model, and A groups were immobilized and restrained for 30 min, six times per week, for 4 weeks. The EA and EA + A groups received EA treatment at specific acupoints for 30 min, six times per week, for 4 weeks. EA parameters were continuous waves at 10 Hz and 1–2 mA. During the intervention, water and food consumption, body weight, fasting blood glucose (FBG), and oral glucose tolerance test (OGTT) were monitored. Pancreatic tissue was examined using hematoxylin and eosin (H&E) staining. Fecal microbial communities were analyzed by 16S rDNA sequencing, and short-chain fatty acids (SCFAs) were measured using gas chromatography–mass spectrometry (GC–MS). Serum levels of fasting insulin (FINS), glycated hemoglobin (HbA1c), and glucagon-like peptide-1 (GLP-1) were determined using enzyme-linked immunosorbent assay (ELISA). Results EA significantly improved daily water intake, food consumption, and body weight in T2DM rats ( p < 0.01). EA also reduced FBG, the area under the curve of the OGTT, FINS, and homeostasis model assessment of insulin resistance (HOMA-IR) in T2DM rats ( p < 0.05). The ELISA results showed a lower concentration of HbA1c in the EA group ( p < 0.05). EA improved the overall morphology and area of pancreatic islets, increased the number of β -cell nuclei, and alleviated β-cell hypertrophy. The abundance of operational taxonomic units (OTUs) in the EA group increased than the model group ( p < 0.05), and EA upregulated the Shannon, Chao1, and Ace indices ( p < 0.05). EA increased the concentrations of acetic acid, butyric acid, and GLP-1 ( p < 0.05). Correlation analysis revealed negative associations between Lactobacillaceae ( R = −0.81, p = 0.015) and Lactobacillus ( R = −0.759, p = 0.029) with FBG. Peptostreptococcaceae and Romboutsia were negatively correlated with HbA1c ( R = −0.81, p = 0.015), while Enterobacteriaceae was positively correlated with OGTT ( R = 0.762, p = 0.028). GLP-1 was positively correlated with acetic acid ( R = 0.487, p = 0.001), butyric acid ( R = 0.586, p = 0.000), isovaleric acid ( R = 0.374, p = 0.017), valeric acid ( R = 0.535, p = 0.000), and caproic acid ( R = 0.371, p = 0.018). Antibiotics disrupted the intestinal microbiota structure and weakened the therapeutic effects of EA. Conclusion EA effectively improved glucose metabolism in T2DM rats. The hypoglycemic effects of EA were associated with the regulation of gut microbiota, SCFAs, and GLP-1.