Soil carbon loss is likely to increase due to climate warming, but microbiomes and microenvironments may dampen this effect. In a 30-year warming experiment, physical protection within soil aggregates affected the thermal responses of soil microbiomes and carbon dynamics. In this study, we combined metagenomic analysis with physical characterization of soil aggregates to explore mechanisms by which microbial communities respond to climate warming across different soil microenvironments. Long-term warming decreased the relative abundances of genes involved in degrading labile compounds (e.g. cellulose), but increased those genes involved in degrading recalcitrant compounds (e.g. lignin) across aggregate sizes. These changes were observed in most phyla of bacteria, especially for Acidobacteria, Actinobacteria, Bacteroidetes, Chloroflexi, and Planctomycetes. Microbial community composition was considerably altered by warming, leading to declined diversity for bacteria and fungi but not for archaea. Microbial functional genes, diversity, and community composition differed between macroaggregates and microaggregates, indicating the essential role of physical protection in controlling microbial community dynamics. Our findings suggest that microbes have the capacity to employ various strategies to acclimate or adapt to climate change (e.g. warming, heat stress) by shifting functional gene abundances and community structures in varying microenvironments, as regulated by soil physical protection.