Soil salinization profoundly threatens agricultural ecosystems by disrupting soil microbial communities and functions, yet the interplay of salinity and depth on microbiome structure and function is unclear. In the present experiment, soils from two depths (0-20 and 20-40 cm) across a low (LS), medium (MS), and high (HS) salinity gradient were collected. The results indicated that the soil electrical conductivity, available sodium, and available potassium were significantly elevated in HS soil. 16S rRNA gene sequencing identified three key microorganisms associated with soil salinity, including Sphingomonas, Bradyrhizobium, and Chloracidobacterium. Metagenomic analysis indicated that the abundances of carbon and nitrogen cycle genes such as amyA, xylA, nifH, nirK, narG and amoA were significantly upregulated in LS soils. In conclusion, the experiment systematically elucidated the intricate restructuring of soil microbiome responses across distinct salinity gradients and depths, providing new theoretical support for the remediation of soil salinization.