RF model outperformed other MLMs in predicting SOC and TN in different aggregate fractions.The highest SOC and TN in macro-aggregates were observed in dense pasture, semi-dense, and orchards.Vegetation indices and topography played a key role in SOC and TN contents in aggregates.Modeling results offer insights into land use planning and sustainable land management practices.Spatial distribution of soil organic carbon (SOC), and total nitrogen (TN) contents in different aggregate fractions (DAFs) were investigated by applying multiple machine learning models (MLMs) i.e., cubist (CB), support vector regression (SVR), and random forest (RF), along with environmental variables in the framework of digital soil mapping (DSM). One hundred samples were taken from the soil surface layer (0-15 cm) in the Aji-Chai watershed, in northwestern Iran. TN and SOC were measured in three soil aggregate sizes (macro, meso, and micro-aggregates). Among the studied machine learning models (MLMs), the RF model revealed exceptional performance and the lowest uncertainty for predicting SOC and TN contents in DAFs. The R2 values for the prediction of SOC in DAFs were 0.86 for SOCmacro, 0.83 for SOCmeso, and 0.81 for SOCmicro. For the TN content in different fractions, the R2 values were ordered as 0.70 for TNmacro, 0.71 for TNmeso, and 0.73 for TNmicro, respectively. Variable importance analysis (VIA) results indicated that factors like vegetation indices such as Corrected transformed vegetation index (CTVI), and normalized difference vegetation index (NDVI), followed by topographic attributes, had a substantial impact in exploring SOC and TN contents in DAFs. In macro-aggregates, the highest SOC and TN contents were found in dense pasture, semi-dense vegetation, and orchards. Conversely, in meso- and micro-aggregates, the lowest contents were observed in rainfed agricultural lands, sparse pastures, and barren regions, respectively. The modeling results open new windows in the field of soil fertility and physics intending to link the content of SOC and TN variation in DAFs. Ultimatly, the RF model demonstrates strong predictive capabilities for SOC and TN contents in DAFs, achieving impressive R2 values. Influential factors include vegetation indices and topography. The resulting prediction maps significantly enhance spatial planning and guide sustainable land management practices, effectively linking soil quality indicators to specific land-use types for improved soil health.