The stormwater biofilter is a prevailing green infrastructure for urban stormwater management, but it is less effective in dissolved nitrogen removal, especially for nitrate. The mechanism that governs the nitrate leaching and performance stability of stormwater biofilters is poorly understood. In this study, a water quality model was developed to predict the ammonium and nitrate dynamics in a biochar-pyrite amended stormwater biofilter. The transport of dissolved nitrogen species was described by advection-dispersion models. The kinetics of adsorption and pyrite-based autotrophic denitrification are included in the model and simulated with a steady-state saturated flow. The model was calibrated and validated using eleven storm events. The modeling results reveal that the contribution of pyrite-based autotrophic denitrification to nitrate leaching alleviation improves with the increased drying duration. The nitrate removal efficiency was affected by a series of design parameters. Pyrite filling rate has a minor effect on nitrate removal promotion. Service area ratio and submerged zone depth are the key parameters to prevent nitrate leaching, as they influence the emergence and discharge time of nitrate breakthrough. The high inflow volume (high service area ratio) and small submerged zone can lead to earlier and increased discharge of peak nitrate otherwise the peak nitrate could be retained in the submerged zone and denitrified during the drying period. The developed mechanistic model provides a useful tool to evaluate the treatment ability of stormwater biofilters under varying conditions and offers a guideline for biofilter design optimization.