Surface ozone (O3) is influenced by regional background and local photochemical formation under favorable meteorological conditions. Understanding the contribution of these factors to changes in O3 is crucial to address the issue of O3 pollution. In this study, we propose a novel integrated method that combines random forest, principal component analysis, and Shapley additive explanations to distinguish observed O3 into meteorologically affected ozone (O3_MET), chemically formed from local emissions (O3_LC), and regional background ozone (O3_RBG). Applied to three typical stations in Shanghai during the warm season from 2013 to 2021, the results indicate that O3_RBG in Shanghai was 48.8 ± 0.3 ppb, accounting for 79.6%–89.4% at different sites, with an overall declining trend of 0.018 ppb/yr. O3_LC at urban and regional sites ranged from 5.9–9.0 ppb and 8.9–14.6 ppb, respectively, which were significantly higher than the contributions of 2.5–7.4 ppb at an upwind background site. O3_MET can be categorized into those affecting O3 photochemical generation and those changing O3 dispersion conditions, with absolute contributions to O3 ranging from 13.4–19.0 ppb and 13.1–13.7 ppb, respectively. We found that the O3 rebound in 2017, compared to 2013, was primarily influenced by unfavorable O3 dispersion conditions and unbalanced emission reductions; while the O3 decline in 2021, compared to 2017, was primarily influenced by overall favorable meteorological conditions and further emissions reduction. These findings highlight the challenge of understanding O3 change due to meteorology and regional background, emphasizing the need for systematic interpretation of the different components of O3.