Salinity is a key driver of microbial community structure and function in salt lake ecosystems, yet how it shapes functional genes involved in carbon (C), nitrogen (N), and phosphorus (P) cycling remains poorly understood. We collected metagenomic samples along a natural salinity gradient in Yuncheng Salt Lake and examined how salinity was associated with microbial taxonomic and functional diversity and with C, N, and P cycling genes. Both diversity metrics decreased significantly with increasing salinity and were positively correlated with each other. The composition and abundance of C, N, and P cycling genes differed significantly among the low-, medium-, and high-salinity groups. In carbon cycling, most carbon fixation genes were more abundant at higher salinity, whereas most carbon degradation genes were less abundant; within carbon fixation, reductive tricarboxylic acid (rTCA) cycle and Calvin cycle gene abundances were higher. In nitrogen cycling, nitrogen mineralization and assimilation genes were significantly more abundant. In phosphorus cycling, transporter and pyrimidine metabolism genes were more abundant, whereas the relative contribution of purine metabolism genes declined. Co-occurrence network analysis revealed dense positive co-occurrence associations among C, N, and P cycling genes, with mer, GLU, and ppk1 as highly connected genes. Mantel tests identified salinity and pH as the primary environmental factors associated with functional gene variation. These results suggest that salinity may regulate C, N, and P cycling genes partly by reshaping microbial community structure in salt lake ecosystems.