The level of genetic differentiation between populations is determined by the homogenizing action of gene flow balanced against differentiating processes such as local adaptation, different adaptive responses to shared environments, and random genetic drift. Geography often limits dispersal, so that the rate of migration is higher between nearby populations and lower between more distant populations. The combination of local genetic drift and distance-limited migration results in local differences in allele frequencies, the magnitude of which increases with geographic distance, resulting in a pattern of isolation by distance (Wright 1943). Extensive theoretical work has described expected patterns of isolation by distance under a variety of models of genetic drift and migration (Charlesworth et al. 2003) in both equilibrium populations in which migration and drift reach a balance, and under nonequilibrium demographic models, such as population expansion or various scenarios of colonization (Slatkin 1993). A range of theoretical approaches have been applied, with authors variously computing probabilities of identity of gene lineages (e.g., Malécot 1975; Rousset 1997) or correlations in allele frequencies (e.g., Slatkin and Maruyama 1975; Weir and Cockerham 1984), or working with the structured coalescent (e.g., Hey 1991; Nordborg and Krone 2002). Although these approaches differ somewhat in detail, their expectations can all be described by a pattern in which allele frequencies are more similar between nearby populations than between distant ones.

In addition to geographic distance, populations can also be isolated by ecological and environmental differences if processes such as dispersal limitations (Wright 1943), biased dispersal (e.g., Edelaar and Bolnick 2012), or selection against migrants due to local adaptation (Wright 1943; Hendry 2004) decrease the rate of successful migration. Thus, in an environmentally heterogeneous landscape, genome-wide differentiation may increase between populations as either geographic distance or ecological distance increase. The relevant ecological distance may be distance along a single environmental axis, such as difference in average annual rainfall, or distance along a discrete axis describing some landscape or ecological feature not captured by pairwise geographic distance, such as being on serpentine versus nonserpentine soil, or being on different host plants.

Isolation by distance has been observed in many species (Vekemans and Hardy 2004; Meirmans 2012), with a large literature focusing on identifying other ecological and environmental correlates of genomic differentiation. The goals of these empirical studies are generally (1) to determine whether an ecological factor is playing a role in generating the observed pattern of genetic differentiation between populations; and (2) if it is, to determine the strength of that factor relative to that of geographic distance. The vast majority of this work makes use of the partial Mantel test to assess the association between pairwise genetic distance and ecological distance while accounting for geographic distance (Smouse et al. 1986).

A number of valid objections have been raised to the reliability and interpretability of the partial Mantel (e.g., Legendre and Fortin 2010; Guillot and Rousset 2013). First, because the test statistic of the Mantel test is a matrix correlation, it assumes a linear dependence between the distance variables, and will therefore behave poorly if there is a nonlinear relationship (Legendre and Fortin 2010). Second, the Mantel and partial Mantel tests can exhibit high false positive rates when the variables measured are spatially autocorrelated (e.g., when an environmental attribute, such as serpentine soil, is patchily distributed on a landscape), because this structure is not accommodated by the permutation procedure used to assess significance (Guillot and Rousset 2013). Finally, in our view the greatest limitation of the partial Mantel test in its application to landscape genetics may be that it is only able to answer the first question posed earlier—whether an ecological factor plays a role in generating a pattern of genetic differentiation between populations—rather than the first *and* the second—the strength of that factor relative to that of geographic distance. By attempting to control for the effect of geographic distance with matrix regressions, the partial Mantel test makes it hard to simultaneously infer the effect sizes of geography and ecology on genetic differentiation, and because the correlation coefficients are inferred for the matrices of postregression residuals, the inferred effects of both variables are not comparable—they are not in a common currency. We perceive this to be a crucial lacuna in the populations genetics methods toolbox, as studies quantifying the effects of local adaptation (e.g., Rosenblum and Harmon 2011), host-associated differentiation (e.g., Drès and Mallet 2002; Gómez-Díaz et al. 2010), or isolation over ecological distance (e.g., Andrew et al. 2012; Mosca et al. 2012) all require rigorous comparisons to the effect of isolation by geographic distance.

In this article, we present a method that enables users to quantify the relative contributions of geographic distance and ecological distance to genetic differentiation between sampled populations or individuals. To do this, we borrow tools from geostatistics (Diggle et al. 1998) and model the allele frequencies at a set of unlinked loci as spatial Gaussian processes. We use statistical machinery similar to that employed by the Smooth and Continuous AssignmenTs (SCAT) program designed by Wasser et al. (2004) and the BayEnv and BayEnv2 programs designed by Coop et al. (2010) and Günther and Coop (2013). Under this model, the allele frequency of a local population deviates away from a global mean allele frequency specific to that locus, and populations covary, to varying extent, in their deviation from this global mean. We model the strength of the covariance between two populations as a decreasing function of the geographic and ecological distance between them, so that populations that are closer in space or more similar in ecology tend to have more similar allele frequencies. We note that this model is not an explicit population genetics model, but a statistical model—we fit the observed spatial pattern of genetic variation, rather than modeling the processes that generated it. Informally, we can think of this model as representing the simplistic scenario of a set of spatially homogeneous populations at migration–drift equilibrium under isolation by distance.

The parameters of this model are estimated in a Bayesian framework using a Markov chain Monte Carlo algorithm (Metropolis et al. 1953; Hastings 1970). We demonstrate the utility of this method with two previously published data sets. The first is a data set from several subspecies of *Zea mays*, known collectively as teosinte (Fang et al. 2012), in which we examine the contribution of difference in elevation to genetic differentiation between populations. The second is a subset of the Human Genome Diversity Panel (HGDP; Conrad et al. 2006; Li et al. 2008), for which we quantify the effect size of the Himalaya mountain range on genetic differentiation between human populations. We have coded this method—Bayesian Estimation of Differentiation in Alleles by Spatial Structure and Local Ecology (BEDASSLE)—in a user-friendly format in the statistical platform R (R Development Core Team 2013), and have made the code available for download at genescape.org.