Background: Dietary energy and protein play important roles in rumen fermentation. However, the comprehensive impacts of dietary energy and protein on rumen bacterial composition and ruminal metabolites were largely unknown. Therefore, the objective of the current study was to investigate the changes in rumen bacterial community and metabolites in response to the diets with simultaneous changes of dietary energy and protein levels in Shaanbei white cashmere goats (SWCG). Methods: A total of 12 ruminal samples were collected from SWCG, which were divided into two groups, including high-energy and high-protein (Group H; crude protein, CP: 9.37% in dry matter; metabolic energy, ME: 9.24 MJ/kg) or control (Group C; CP: 8.73%; ME:8.60 MJ/kg) groups. The experiment lasted for 65 days, including 10 days for adaptation. 16S rRNA gene sequencing and quantitative real-time polymerase chain reaction (qRT-PCR) were performed to identify the rumen bacterial community. Metabolomics analysis was done to investigate the rumen metabolites and the related metabolic pathways in Groups C and H. Results: The study observed 539 genera belonging to 30 phyla, which were distributed throughout the rumen samples. The high-energy and high-protein diets increased the relative abundance of phylum Bacteroidetes and genera Prevotella_1 and Succiniclasticum, while decreased the number of phylum Proteobacteria (p<0.05). Among the 24 differential metabolites (VIP>1.0, p<0.05) detected in this study, the dominant differential metabolites were amino acids, peptides and analogs. Tyrosine metabolism played an important role among the 9 main metabolic pathways. Correlation analysis revealed that Prevotella_1 showed strong positive correlation with 5-methoxyindole-3-acetic acid (r=0.601, p<0.05) and catechol (r=0.608, p<0.05). Succiniclasticum was positively correlated with 2-ketoadipate (r=0.741, p<0.01). Conclusions: Our findings revealed that the diets with high energy and protein in Group H significantly altered the composition of ruminal bacteria and metabolites, which could help to improve the dietary energy and protein use efficiency in goats.