A prediction of the hypothesis that niche processes control plant species distributions across edaphic gradients is that pairwise comparisons of related species on contrasting soils should show consistent patterns of trait divergence. This hypothesis was tested in lowland Bornean rain forest by combining measurements of leaf traits, soil nutrients and the distribution of tree species in the Dipterocarpaceae across a nutrient gradient. Nine species were studied, comprising four related pairs in Shorea (phylogenetic independent contrasts; PICs) and one habitat generalist (Dipterocarpus sublamellatus). Lamina area, specific leaf area (SLA), leaf nitrogen (N) and phosphorus (P) were measured for ∼10 saplings of each species; habitat associations were defined as a continuous function of soil nutrients and categorically in relation to substrate. Species distributions and traits varied significantly with soil nutrients. When all species were pooled, SLA and leaf P increased significantly with species' distribution across the nutrient gradient; leaf N showed the same trend. Trait shifts with habitat were stronger and more pervasive when habitat was defined categorically – in all four PICs, rich-soil specialists had larger leaves, higher SLA, leaf N and P, and lower N:P ratios. Trait shifts with habitat at least partly reflect intrinsic differences between species. Within Shorea, variation in lamina area and N:P ratio were more strongly related to phylogeny than habitat, whereas the reverse held for SLA and leaf P. Phylogeny also influenced the extent of trait divergence between related species on different soils, and patterns of trait correlation within lineages. Results support the hypothesis that niche processes influence the distribution of species and traits in lowland tropical tree communities, and highlight the value of phylogenetic information for increasing the power of comparative studies.