Water quality degradation in China’s coastal waters poses a significant ecological challenge, yet the spatially varying predictors of key pollutants remain poorly quantified at the national scale. This study employed a Geographically Weighted Random Forest (GWRF) model integrating meteorological, marine, and socioeconomic data to analyze the associations between potential influencing factors and water quality variations in chemical oxygen demand (COD), dissolved inorganic nitrogen (DIN), and dissolved inorganic phosphorus (DIP) across China’s coastal waters. Results reveal significant spatial heterogeneity and clustering patterns, with distinct “High–High” hotspots and “Low–Low” cold spots for each indicator. The GWRF model showed modest improvements over traditional global models (RF, XGBoost) under spatially structured cross-validation, with significant improvement only for COD. COD variations were jointly associated with meteorological and marine factors, whereas nutrients (DIN, DIP) showed stronger associations with marine environments. Spatialized SHAP effects indicated regional specificities: cropland proportion showed positive effects on COD in Bohai Bay but negative effects in eastern Shandong Peninsula; upper ocean heat content and coastal population density emerged as key contributing factors for DIN; sea surface salinity was closely linked to DIP distribution patterns. These findings provide a systematic quantification of factor contributions at the national scale, offering spatially explicit evidence for formulating differentiated pollution control strategies for China‘s nearshore waters.