Comparative analysis methods control for the variation linked to phylogeny before attempting to correlate the remaining variation of a trait to present-day conditions (i.e., ecology and/or environment). A portion of the phylogenetic variation of the trait may be related to ecology, however; this portion is called “phylogenetic niche conservatism.” We propose a method of variation partitioning that allows users to quantify this portion of the variation, called the “phylogenetically structured environmental variation.” The new method is applied to published data to study, in a phylogenetic framework, the link between body mass and population density in 79 species of mammals. The results suggest that an important part of the variation of mammal body mass is related to the common influence of phylogeny and population density.