This study presents a comprehensive depth wise assessment of metal contamination in soils surrounding oil and gas drilling sites in the Krishna–Godavari (K-G) basin, encompassing the agriculturally intensive East and West Godavari districts of Andhra Pradesh, India. These regions are characterized by fertile alluvial soils, intensive farming, and dense hydrocarbon exploration, making them particularly vulnerable to environmental degradation. Eighty soil samples were collected from ten drilling locations at multiple depths (00–20 cm, 20–30 cm, 30–60 cm, and 60–90 cm) and analysed using WD-XRF to quantify thirteen elements. Pollution levels were evaluated using multiple geochemical indices, including Geo-accumulation Index (Igeo), Enrichment Factor (EF), Contamination Factor (Cf), Modified Degree of Contamination (mCd), Nemerow Pollution Index (NPI), and Metal Pollution Index (MPI). Surface soils showed strong enrichment of Cu, Zn, Cr, and Pb, with notable migration of metals such as Ba, Ni, and Co into deeper soil horizons. This vertical transport is facilitated by factors including soil permeability, texture, irrigation practices, and seasonal monsoonal rainfall, which enhance leaching and subsurface mobility, particularly in sandy clay and alluvial soils. The results revealed significant vertical and spatial heterogeneity, with extreme contamination by Cu, Zn, and Cr observed particularly at drilling-intensive sites, indicating strong anthropogenic influence. PCA and Pearson correlation delineated both geogenic and anthropogenic associations among the elements. PMF modelling identified six distinct source profiles, including geogenic weathering, drilling muds, corrosion by-products, fertilizer application, petroleum residues, and wastewater reuse. Metals such as Cu, Pb, and Cr showed strong enrichment in surface and subsurface layers, while Ba and Sc exhibited geogenic accumulation at deeper horizons. The interactions between hydrocarbon residues and elements, along with soil physicochemical properties, were found to influence metal mobility and bioavailability. The study underscores the ecological vulnerability of hydrocarbon-rich agricultural zones to drilling-induced contamination and highlights the critical need for scientifically informed waste management, policy enforcement, and remediation planning. These findings provide a depth-resolved geochemical baseline essential for sustainable land-use practices, groundwater protection, and long-term environmental monitoring in petroleum extraction zones.