The plant microbiome significantly influences plant health and ecosystem functions, yet its response to environmental change and links to plant diversity are not fully understood. We investigated the impacts of climate warming and nitrogen deposition on leaf epiphytic and endophytic bacterial communities in Stipa breviflora and Cleistogenes songorica over an 18-year field experiment in temperate desert steppe. Results showed increased diversity in both leaf bacterial types, with epiphytic biomass rising and endophytic biomass falling due to distinct mechanisms. Epiphytic diversity and biomass increased with leaf temperature and transpiration rate, endophyte diversity increased with leaf carbon and nitrogen concentrations, and endophytic biomass related to leaf nitrogen and phosphorus levels. Structural equation modeling revealed both epiphytic and endophytic bacterial diversity correlated with reduced plant diversity, which in turn was linked to increased leaf bacterial diversity, indicating a complex response of phyllosphere bacteria to global changes in perennial grassland ecosystems.