The sustainable development of urban agglomerations plays a pivotal role in national and global efforts to reduce emissions. By focusing on the efficient exchange and optimization of energy consumption across various sectors, the sustainable development of energy systems within urban agglomerations can be achieved. However, the overall impact of the cross-sector energy optimization and complementarity has not been quantitatively analyzed. Here, we focused on the Yangtze River Delta (YRD) urban agglomeration in China and proposed an optimization framework for energy, environment, and economy. The framework considered four sectors: transportation sector, power sector, industry sector, and building sector, in order to determine the most sustainable development pathway for the urban agglomeration. The optimization model considers total costs and greenhouse gas emissions reduction as the objectives and utilizes technologies as constraints to optimize the pathway. We found that this optimization strategy resulted in a 53.1 billion tons increase in CO2 emissions reduction in the region. The results of emission reduction varied across sectors, ranging from 4.5 to 22.2 billion tons CO2 equivalent, and across cities, ranging from 7.1 to 4688.1 Mt. The results suggest that the core cities in the urban agglomeration can take on a leadership role. By promoting cross-sector collaboration and implementing energy recycling, the energy efficiency of surrounding cities can be greatly improved, leading to the sustainable development of the urban agglomeration.