A key component of data assimilation methods is the specification of univariate spatial correlations, which appear in the background-error covariance. For realistic problems in meteorology and oceanography, correlation length scales are nonstationary (variable in space) and anisotropic (variable in each direction). Variational approaches typically use an operator to enforce correlation length scales, and thus the operator must be designed to capture desired levels of nonstationarity and anisotropy. For systems with complex boundaries, such as the ocean, it is natural to use a filtering approach based on the application of an elliptic, Laplacian-like operator. Here we show how an elliptic operator can be formulated to capture a general Matérn-type correlation structure. We show how nonstationarity and anisotropy can be encoded into the operator via a simple change of variables based on user-defined normalization length scales. The change of variables defines a mapping between the computational domain and a space where the analytical Matérn correlation function applies. In addition to the mapping, two other hyperparameters separately control the correlation length scale (i.e. range) and shape. As a practical use-case, we apply the operator to a global ocean model. We show that when the normalizing length scales correspond to the local grid scale, the range parameter has an intuitive interpretation as the number of neighboring grid cells at which correlation drops to 0.14. Finally, the correlation model is shown to be computationally efficient in two regards. First, the necessary linear solve can be performed with a high tolerance (∼10^{-3}) while still achieving the correct statistics, requiring few iterations to converge. Secondly, the operator’s exponent, which controls the correlation shape, is linearly related to the diagonal elements of its matrix representation. As a result, using an exponent greater than one can improve convergence properties. Thus, the framework provides flexibility in controlling correlation shape.