The goal of making nutrient removal wastewater treatment energy self-sufficient or even energy producing has become a worldwide accepted goal of technology development. The latest upgrade of the Vienna Main Wastewater Treatment Plant (VMWWTP) with a design capacity of 4 million (M) population equivalent (PE) will produce about 20% more energy on a yearly basis than needed for operation due to a special process scheme. It consists of primary sedimentation, a special 2-stage activated sludge (AS) process configuration where excess sludge is only withdrawn from the first stage AS plant. Raw sludge is subject to mechanical thickening to ∼8% digested sludge (DS) for digestion at high solids concentration. The reject water after nitritation is used for denitritation in the first stage AS plant. This results in markedly reducing the energy requirement for aeration. The design of this last upgrade for energy optimization of sludge treatment is based on the long-term full-scale data from the existing plant, results of mid-term pilot investigations, sound theoretical mass balance calculations and an adapted dynamic model development. All this is presented in this paper. The full-scale upgrade is under construction and will start operating in 2020.