This paper presents the application of a plant-wide model-based methodology to wastewater treatment plants. The focus is on a tertiary activated sludge plant with anaerobic sludge treatment, owned and operated by Sydney Water. A dynamic plant-wide model is first developed and calibrated using historical data. A scenario-based optimization procedure is then applied for computing the effect of key discharge constraints on the minimal net power consumption, via the repeated solution of a dynamic optimization problem. The results show a potential for reduction of the energy consumption by about 20%, through operational changes only, without compromising the current effluent quality. It is also found that nitrate (and hence total nitrogen) discharge could be reduced from its current level around 22 mg(N)/L to less than 15 mg(N)/L with no increase in net power consumption, and could be further reduced to <10 mg(N)/L subject to a 15% increase in net power consumption upon diverting part of the primary sludge to the secondary treatment stage. This improved understanding of the relationship between nutrient removal and energy use will feed into discussions with environmental regulators regarding nutrient discharge licensing.