The aims of the study are the description of the distribution patterns of main forest tree species along complex environmental gradients and niche characterization, using the data from772 plots fromthe third Spanish National Forest Inventory. Simultaneously, we would like to identify the relative contribution of spatial and environmental variation to the species compositional patterns. Spatially structured environmental and fine-scale spatial variables explained more tree compositional distribution than broad-scale spatial variables, suggesting that niche partitioning is the main process influencing forest species abundances along this gradient. However, vegetation compositional changes were mainly determined by the north–south topographic-climatic differences (primary coenocline), although steepnesswas also related to the particular location of some plant communities. Unimodal response curves dominate along the gradients, with tree species optima at different points, providing evidence of a sufficient amount of compositional turnover. Niche location of trait-related tree species is closely located. Tree species occupying environments with sharp contrast or transitional environments have broadest niches, whereas those species occupying localized habitats showedthe narrowest niches. The methodologyused provides an objective assessment of the shape of species’ responses along complex ecological gradients, as well as of the spatial and environmental factors implicated in their distribution patterns using datasets from national forest inventories. The description of the main factors determining the gradients and the species distributions and niche characteristics will improve our ability to discuss potential conservation management goals or threats due to land uses changes and future climate change.