Aim In ectotherms, the colour of an individual’s cuticle may have important thermoregulatory and protective consequences. In cool environments, ectotherms should be darker, to maximize heat gain, and larger, to minimize heat loss. Dark colours should also predominate under high UV-B conditions because melanin offers protection. We test these predictions in ants (Hymenoptera: Formicidae) across space and through time based on a new, spatially and temporally explicit, global-scale combination of assemblage-level and environmental data. Location Africa, Australia and South America. Methods We sampled ant assemblages (n5274) along 14 elevational transects on three continents. Individual assemblages ranged from 250 to 3000 m a.s.l. (minimum to maximum range in summer temperature of 0.5–35 8C). We used mixed-effects models to explain variation in assemblage cuticle lightness. Explanatory variables were average assemblage body size, temperature and UVB irradiation. Annual temporal changes in lightness were examined for a subset of the data. Results Assemblages with large average body sizes were darker in colour than those with small body sizes. Assemblages became lighter in colour with increasing temperature, but darkened again at the highest temperatures when there were high levels of UV-B. Through time, temperature and body size explained variation in lightness. Both the spatial and temporal models explained c. 50% of the variation in lightness. Main conclusions Our results are consistent with the thermal melanism hypothesis, and demonstrate the importance of considering body size and UVB radiation exposure in explaining the colour of insect cuticle. Crucially, this finding is at the assemblage level. Consequently, the relative abundances and identities of ant species that are present in an assemblage can change in accordance with environmental conditions over elevation, latitude and relatively short time spans. These findings suggest that there are important constraints on how ectotherm assemblages may be able to respond to rapidly changing environmental conditions.