Climate change is increasing the frequency and intensity of heatwaves, raising concerns about their detrimental effects on air quality. However, a role for heatwave-human-environment interactions in air pollution exacerbation has not been established. In the summer of 2022, record-breaking heatwaves struck China and Europe. In this study, we use integrated observational data and machine learning to elucidate the formation mechanism underlying one of the most severe ozone pollution seasons on record in central eastern China, an area that encompasses approximately half of China’s total population and sown land. Our findings reveal that the worsened ozone and nitrogen dioxide pollution resulted from a mismatch between energy demand and supply, which was driven by both heatwaves and energy policy-related factors. The observed adverse heatwave-energy-environment feedback loop highlights the need for the diversification of clean energy sources, more resilient energy structures and power policies, and further emission control to confront the escalating climate challenge in the future.