Evidence on the effect of natural environments on atopy in children is limited and inconsistent, disregarding the time-varying and cumulative exposures throughout the life course. To assess critical periods of exposure as well as the effect of longitudinal trajectories of exposure to green and blue spaces on the development of allergic sensitization in children at the age of 10 years. A longitudinal study was conducted involving 730 children enrolled in Generation XXI, a population-based birth cohort from the Porto Metropolitan Area (Portugal). Food and aeroallergens sensitization were evaluated at 10 years of age using Phadiatop Infant, Phadiatop fx1 and fx22 ImmunoCAP (Thermo Fisher Scientific, Uppsala, Sweden). Residential Normalized Difference Vegetation Index (NDVI) and distance to the nearest blue space (sea, river) were assessed using a Geographic Information System. Latent class linear mixed models were fitted to determine longitudinal trajectories of exposure. Associations were estimated using Cox proportional hazards regression models and expressed using hazard ratios (HR) and 95% confidence intervals (95% CI). Residing in neighbourhoods surrounded by more vegetation at 10 years, as well as lifetime exposure to a trajectory of higher levels of NDVI, were associated with a lower risk of allergic sensitization [HR (95% CI) = 0.095 (0.011, 0.823) and HR (95% CI) = 0.539 (0.301, 0.965), respectively]. Our findings support a role for both longitudinal, but particularly late-childhood, exposure to green spaces, in the prevention of allergic sensitization in children.