We assessed the association between the natural environment and asthma in 49,956 New Zealand children born in 1998 and followed up until 2016 using routinely collected data. Children who lived in greener areas, as measured by the normalized difference vegetation index, were less likely to be asthmatic: a 1 s.d. increase in normalized difference vegetation index was associated with a 6.0% (95% CI 1.9–9.9%) lower risk of asthma. Vegetation diversity was also protective: a 1 s.d. increase in the number of natural land-cover types in a child’s residential meshblock was associated with a 6.7% (95% CI 1.5–11.5%) lower risk. However, not all land-cover types were protective. A 1 s.d. increase in the area covered by gorse (Ulex europaeus) or exotic conifers, both non-native, low-biodiversity land-cover types, was associated with a 3.2% (95% CI 0.0–6.0%) and 4.2% (95% CI 0.9–7.5%) increased risk of asthma, respectively. The results suggest that exposure to greenness and vegetation diversity may be protective of asthma.