Prediction of the long-term risk of trace metals leaching from soils at smelting sites is essential for groundwater protection. Herein, a mass balance-based stochastic model was developed to simulate the transport and probabilistic risks of trace metals in heterogeneous slag-soil-groundwater systems. The model was applied to a smelting slag yard with three stacking scenarios, including (A) fixed stacking amount, (B) stacking amount increasing yearly, and (C) slag removal after 20 years. The simulations suggested that the leaching flux and net accumulation of Cd in soils of the slag yard and abandoned farmland were greatest for scenario (B), which was followed by scenarios (A) and (C). In the slag yard, a plateau occurred in the Cd leaching flux curves, followed by a sharp increase. After 100 years of leaching, only scenario (B) had a high probabilistic risk (>99.9 %) of threatening groundwater safety under heterogeneous conditions. <11.1 % of the exogenous Cd may leach into groundwater under the worst scenario. The key parameters affecting Cd leaching risk include runoff interception rate (IRCR), input flux from slag release (I), and stacking time (ST). The simulation results were consistent with the values measured in a field investigation and laboratory leaching experiments. The results should help guide remediation objectives and measures to minimize the leaching risk at smelting sites.