Soil microbial communities in Mediterranean agroecosystems experience long drought periods that are typically combined with heat and frequently interspersed with rapid rewetting events. Agroforestry systems are of growing interest and viewed as possible alternative to conventional cropping systems in the context of climate change. Our aim was to evaluate the resistance and resilience of soil microbial communities against drought with or without heat stress at different distances from the tree row in an agroforestry system as compared to a conventional cropping system. Soils were sampled at several distances from the tree row in a 21-year-old walnut agroforestry system and a contiguous conventional crop in Southern France. We simulated two cycles of drying-rewetting under controlled conditions and applied three distinct treatments: control (without stress), drought and drought combined with heat stress. We monitored microbial respiration over the incubation period. The inorganic N and microbial biomass C, N and P contents (MBC, MBN and MBP) were assessed during the drying period (resistance), just after rewetting and at the end of the experiment (resilience), while bacterial and fungal abundances were measured at the end of the resistance period. We demonstrated that an agroforestry system can induce spatial heterogeneity in soil microbial biomass and functions under control conditions. Microbial biomass and activity, soil organic matter (SOM) and mineral N levels increased on the tree row. This spatial heterogeneity pattern was preserved for soil microbial response to drought combined or not with heat. Microorganisms sampled in the middle of the interrow or in the conventional crop exhibited highest biomass resistance and lowest resilience when facing combined drought and heat stress. Soil microbial biomass resistance and resilience were similar whatever the spatial position when microorganisms had to deal with drought stress only. Our findings suggested that despite higher SOM content, microbial biomass and activity at and near the tree row, the legacy effect of the tree row did not lead to higher ecological stability under stressful climatic conditions. We also demonstrated that soil microorganisms can considerably change their stoichiometry depending on the stress treatment. Soil microorganisms showed elevated MBC:MBN, MBC:MBP and variable MBN:MBP during the resistance period. A high stoichiometric flexibility of microorganisms was observed when exposed to drought stress only, while stoichiometric changes were irreversible when exposed to combined drought and heat stress.