The methods of direct gradient analysis and variation partitioning are the most widely used frameworks to evaluate the contributions of species sorting to metacommunity structure. In many cases, however, species are also driven by spatial processes that are independent of environmental heterogeneity (e.g., neutral dynamics). As such, spatial autocorrelation can occur independently in both species (due to limited dispersal) and the environmental data, leading to spurious correlations between species distributions and the spatialized (i.e., spatially-autocorrelated) environment. In these cases, the method of variation partitioning may present high Type I error rates (i.e., reject the null hypothesis more often than the pre-established critical level) and inflated estimates regarding the environmental component that is used to estimate the importance of species sorting. In this paper, we (1) demonstrate that metacommunities driven by neutral dynamics (via limited dispersal) alone or in combination with species sorting leads to inflated estimates and Type I error rates when testing for the importance of species sorting; and (2) propose a general and flexible new variation partitioning procedure to adjust for spurious contributions due to spatial autocorrelation from the environmental fraction. We used simulated metacommunity data driven by pure neutral, pure species sorting, and mixed (i.e. neutral + species sorting dynamics) processes to evaluate the performances of our new methodological framework. We also demonstrate the utility of the proposed framework with an empirical plant dataset in which we show that half of the variation initially due to the environment by the standard variation partitioning framework was due to spurious correlations.