The conversion of mountainous karst forests into urban parks necessitates a critical analysis of its impact on existing ecosystems, particularly regarding soil microbial diversity and its role in carbon and nitrogen cycling. Our study targeted three established mountain parks in Guiyang, China, to discern the effects of habitat alteration and park age on the soil microbiota’s functional genes. The findings indicated pronounced differences in functional gene profiles between original remnant forests and created greenspaces. The artificial green spaces exhibited a heightened presence of genes related to aerobic methane oxidation, anaerobic carbon fixation, denitrification and nitrification, indicating that artificial green spaces may cultivate soil microbial communities with enhanced metabolic versatility. We revealed a positive correlation between soil nitrogen levels and the abundance of genes involved in various processes of the carbon and nitrogen cycles in these artificial green areas, highlighting the critical role of nitrogen in influencing the structure of microbial communities. Soil chemical properties (namely C, N, P, K content) and habitat type emerged as the most consequential for the gene composition related to the carbon and nitrogen cycles. The co-occurrence networks of functional genes constructed for these cycles suggest a tendency towards synergistic microbial interactions. To safeguard the interplay between human recreation and the conservation of native ecosystems, we recommend the integration of native flora preservation and meticulous soil condition management into the strategies for developing urban mountain parks.