Abstract Ancient trees are vital evolutionary resources for ecosystems in a changing world. Although being fundamental anchors of many natural processes, the causes leading to their extreme longevity are still partly unknown. Here, we aim to unveil how specific habitat features and selective pressures influence functional traits of long-living trees that support extreme tree age. During the period 2022-2024, we monitored 13 forests covering the entire age range of mountain pine and silver fir in the Pyrenees. Results reveal that extreme tree longevity requires the prevalence of complex habitat structures settled over millennia. Lifespan is limited in forests with common and homogeneous habitat attributes, preventing the maximum attainable lifespan of trees to occur. In longevity hotspots, however, some functional traits deployed in response to specific habitat features and evolutionary pressures lengthen longevity for several centuries. Our findings revitalise the idea of extreme tree longevity as a fundamental spatiotemporal process that depends on habitat structure. Moreover, we show that current maximum attainable lifespan has been reduced in most forests due to habitat alteration.