• Background and Aims Identifying the processes that generate and maintain biodiversity requires understanding of how evolutionary processes interact with abiotic conditions to structure communities. Edaphic gradients are strongly associated with floristic patterns but, compared with climatic gradients, have received relatively little attention. We asked (1) How does the phylogenetic composition of palm communities vary along edaphic gradients within major habitat types? and (2) To what extent are phylogenetic patterns determined by (a) habitat specialists, (b) small versus large palms, and (c) hyperdiverse genera? • Methods We paired data on palm community composition from 501 transects of 0.25 ha located in two main habitat types (non-inundated uplands and seasonally inundated floodplains) in western Amazonian rain forests with information on soil chemistry, climate, phylogeny and metrics of plant size. We focused on exchangeable base concentration (cmol + kg −1) as a metric of soil fertility and a floristic index of inundation intensity. We used a null model approach to quantify the standard effect size of mean phylogenetic distance for each transect (a metric of phylogenetic community composition) and related this value to edaphic variables using generalized linear mixed models, including a term for spatial autocorrelation. • Key Results Overall, we recorded 112 008 individuals belonging to 110 species. Palm communities in non-inundated upland transects (but not floodplain transects) were more phylogenetically clustered in areas of low soil fertility, measured as exchangeable base concentration. In contrast, floodplain transects with more severe flood regimes (as inferred from floristic structure) tended to be phylogenetically clustered. Nearly half of the species recorded (44 %) were upland specialists while 18 % were floodplain specialists. In both habitat types, phylogenetic clustering was largely due to the co-occurrence of small-sized habitat specialists belonging to two hyperdiverse genera (Bactris and Geonoma). • Conclusions Edaphic conditions are associated with the phylogenetic community structure of palms across western Amazonia, and different factors (specifically, soil fertility and inundation intensity) appear to underlie diversity patterns in non-inundated upland versus floodplain habitats. By linking edaphic gradients with palm community phylogenetic structure, our study reinforces the need to integrate edaphic conditions in eco-evolutionary studies in order to better understand the processes that generate and maintain tropical forest diversity. Our results suggest a role for edaphic niche conservatism in the evolution and distribution of Amazonian palms, a finding with potential relevance for other clades.