Cross-sectional evidence suggests that living near green and blue spaces benefits mental health; longitudinal evidence is limited. To quantify the impact of changes in green and blue spaces on common mental health disorders, well-being and health service use. A retrospective, dynamic longitudinal panel study. Wales, UK. An e-cohort comprising 99,682,902 observations of 2,801,483 adults (≥ 16 years) registered with a general practice in Wales (2008-2019). A 5312-strong 'National Survey for Wales (NSW) subgroup' was surveyed on well-being and visits to green and blue spaces. Common mental health disorders, general practice records; subjective well-being, Warwick-Edinburgh Mental Well-being Scale. Common mental health disorder and use of general practice services were extracted quarterly from the Welsh Longitudinal General Practice Dataset. Annual ambient greenness exposure, enhanced vegetation index and access to green and blue spaces (2018) from planning and satellite data. Data were linked within the Secure Anonymised Information Linkage Databank. Multilevel regression models examined associations between exposure to green and blue spaces and common mental health disorders and use of general practice. For the National Survey for Wales subgroup, generalised linear models examined associations between exposure to green and blue spaces and subjective well-being and common mental health disorders. Our longitudinal analyses found no evidence that changes in green and blue spaces through time impacted on common mental health disorders. However, time-aggregated exposure to green and blue spaces contrasting differences between people were associated with subsequent common mental health disorders. Similarly, our cross-sectional findings add to growing evidence that residential green and blue spaces and visits are associated with well-being benefits: Greater ambient greenness (+ 1 enhanced vegetation index) was associated with lower likelihood of subsequently seeking care for a common mental health disorder [adjusted odds ratio (AOR) 0.80, 95% confidence interval, (CI) 0.80 to 0.81] and with well-being with a U-shaped relationship [Warwick-Edinburgh Mental Well-being Scale; enhanced vegetation index beta (adjusted) -10.15, 95% CI -17.13 to -3.17; EVI2 beta (quadratic term; adj.) 12.49, 95% CI 3.02 to 21.97]. Those who used green and blue spaces for leisure reported better well-being, with diminishing extra benefit with increasing time (Warwick-Edinburgh Mental Well-being Scale: time outdoors (hours) beta 0.88, 95% CI 0.53 to 1.24, time outdoors2 beta -0.06, 95% CI -0.11 to -0.01) and had 4% lower odds of seeking help for common mental health disorders (AOR 0.96, 95% CI 0.93 to 0.99). Those in urban areas benefited most from greater access to green and blue spaces (AOR 0.89, 95% CI 0.89 to 0.89). Those in material deprivation benefited most from leisure time outdoors (until approximately four hours per week; Warwick-Edinburgh Mental Well-being Scale: time outdoors × in material deprivation: 1.41, 95% CI 0.39 to 2.43; time outdoors2 × in material deprivation -0.18, 95% CI -0.33 to -0.04) although well-being remained generally lower. Longitudinal analyses were restricted by high baseline levels and limited temporal variation in ambient greenness in Wales. Changes in access to green and blue spaces could not be captured annually due to technical issues with national-level planning datasets. Further analyses could investigate mental health impacts in population subgroups potentially most sensitive to local changes in access to specific types of green and blue spaces. Deriving green and blue spaces changes from planning data is needed to overcome temporal uncertainties. This project was funded by the National Institute for Health and Care Research (NIHR) Public Health Research programme (Project number 16/07/07) and will be published in full in Public Health Research; Vol. 11, No. 10. Sarah Rodgers is part-funded by the NIHR Applied Research Collaboration North West Coast.