This paper proposes a novel optimization method that allows a reduction in the pollutant emission of diesel engines during transient operation. The key idea is to synthesize optimal actuator commands using reliable models of the engine system and powerful numerical optimization methods. The engine model includes a mean-value engine model for the dynamics of the gas paths, including the turbocharger of the fuel injection, and of the torque generation. The pollutant formation is modeled using an extended quasi-static modeling approach. The optimization substantially changes the input signals, such that the engine model is enabled to extrapolate all relevant outputs beyond the regular operating area. A feedforward controller for the injected fuel mass is used to eliminate the nonlinear path constraints during the optimization. The model is validated using experimental data obtained on a transient engine test bench. A direct single shooting method is found to be most effective for the numerical optimization. The results show a significant potential for reducing the pollutant emissions during transient operation of the engine. The optimized input trajectories derived assist the design of sophisticated engine control systems.