In clinical trials, one may be interested in the treatment effect on both the surrogate end point (i.e., an intermediate event) and the primary end point (i.e., a terminal event). The analyses of both events constitute a semi-competing risks problem where the surrogate end point may be censored by the primary end point, but not vice versa. Here we propose a nonparametric approach casting the semi-competing risks problem in the framework of causal mediation modeling. We set up a mediation model with the intermediate and terminal events, respectively as the mediator and the outcome, and define indirect effect as the effect of the exposure on the primary event mediated by the intermediate event and direct effect as that not mediated by the intermediate event. A nonparametric estimator is proposed for direct and indirect effects, which can be viewed as a Nelson-Aalen estimator with time-varying weights. Theoretical properties such as asymptotic unbiasedness, consistency and asymptotic normality are established for the proposed estimator. Numerical simulation and data application are presented to illustrate the finite sample performance and utility of the proposed method.