To assess the long-term impact of residential air pollution and green space exposure on cause-specific mortality in individuals with type 2 diabetes mellitus (T2DM). This study includes 174,063 participants newly diagnosed with T2DM from a prospective cohort in Shanghai, China, enrolled between 2011 and 2013. Residential annual levels of air pollutants, including fine (PM2.5) and coarse (PM2.5-10) particulate matter, nitrogen dioxide (NO2), along with the normalized difference vegetation index (NDVI), were derived from satellite-based exposure models. During a median follow-up of 7.9 years (equivalent to 1,333,343 person-years), this study recorded 22,205 deaths. Higher exposure to PM2.5 was significantly associated with increased risks for all mortality outcomes, whilst PM2.5-10 showed no significant impacts. The strongest associations of PM2.5 were observed for diabetes with peripheral vascular diseases [hazard ratio (HR): 2.70; per 10μg/m3 increase] and gastrointestinal cancer (2.44). Effects of NO2 became significant at concentrations exceeding approximately 45μg/m³, with the highest associations for lung cancer (1.20) and gastrointestinal cancer (1.19). Conversely, each interquartile range increase in NDVI (0.10) was linked to reduced mortality risks across different causes, with HRs ranging from 0.76 to 1.00. The association between greenness and mortality was partly and significantly mediated by reduced PM2.5 (23.80%) and NO2 (26.60%). There was a significant and negative interaction between NO2 and greenness, but no interaction was found between PM2.5 and greenness. Our findings highlight the vulnerability of individuals with T2DM to the adverse health effects of air pollution and emphasise the potential protective effects of greenness infrastructure. The 6th Three-year Action Program of Shanghai Municipality for Strengthening the Construction of Public Health System (GWVI-11.1-22), the National Key Research and Development Program (2022YFC3702701), and the National Natural Science Foundation of China (82030103, 82373532).