Abstract Land abandonment promotes forest expansion into abandoned agricultural lands in Europe. This process leads to changes that affect several ecosystem services, but it is considered a low‐cost strategy to restore soil functions in past agricultural lands. Soil microbial communities play a key role in restoring functions. However, the relationship among forest expansion, microbial communities, and soil functioning is unclear. In this study, we used a Juniperus thurifera expansion gradient on abandoned agricultural lands in Alto Tajo National Park (Spain) to discover the changes elicited by the soil microbial communities and their functions along this gradient considering two microhabitats, under the canopy and open areas. Specifically, our objectives were (i) to analyse how soil properties (organic matter and pH), microbial communities (using PLFAs‐NFLAs) and enzymatic activities (related to C, N and P cycling) varied along the forest expansion gradient and between microhabitats and (ii) to decipher the pathways by which soil properties control the carbon and nutrient cycling in soils. The forest expansion gradient had a direct negative effect on phosphatase activity. The microhabitat showed a positive direct effect on organic matter content, pH, actinomycetes and arbuscular mycorrhizal fungi biomass and on soil C and P cycling. Moreover, the biomass of gram‐positive bacteria determined the biomass of other microbial groups. Synthesis and Applications: Though its effectiveness is variable, passive restoration can be more effective than active restoration. Our research indicates that passive tree colonisation of past agricultural land is enough to achieve soil functionality similar to a mature forest for most variables studied. However, some variables would need more time to reach mature forest levels, such as total microbial biomass and organic matter content. Therefore, to support ecosystem recovery, the management of this applied forest ecology strategy requires continuous monitoring of newly established trees and soil to elucidate the time needed to achieve mature soil properties.