In this work, a predictive supervisory controller is presented that optimizes the interaction between a diesel engine and its aftertreatment system (ATS). The fuel consumption is minimized while respecting an upper bound on the emitted tailpipe NOx mass. This is achieved by optimally balancing the fuel consumption, the engine-out NOx emissions, and the ATS heating. The proposed predictive supervisory controller employs a two-layer model predictive control structure and solves the optimal control problem using a direct method. Through experimental validation, the resulting controller was shown to reduce the fuel consumption by 1.1% at equivalent tailpipe NOx emissions for the nonroad transient cycle when compared to the operation with a fixed engine calibration. Further, the controller’s robustness to different missions, initial ATS temperatures, NOx limits, and mispredictions was demonstrated.