Maximum lifespan in birds and mammals varies strongly with body mass such that large species tend to live longer than smaller species. However, many species live far longer than expected given their body mass. This may reflect interspecific variation in extrinsic mortality, as life-history theory predicts investment in long-term survival is under positive selection when extrinsic mortality is reduced. Here, we investigate how multiple ecological and mode-of-life traits that should reduce extrinsic mortality (including volancy (flight capability), activity period, foraging environment and fossoriality), simultaneously influence lifespan across endotherms. Using novel phylogenetic comparative analyses and to our knowledge, the most species analysed to date (n ¼ 1368), we show that, over and above the effect of body mass, the most important factor enabling longer lifespan is the ability to fly. Within volant species, lifespan depended upon when (day, night, dusk or dawn), but not where (in the air, in trees or on the ground), species are active. However, the opposite was true for non-volant species, where lifespan correlated positively with both arboreality and fossoriality. Our results highlight that when studying the molecular basis behind cellular processes such as those underlying lifespan, it is important to consider the ecological selection pressures that shaped them over evolutionary time.