Gravity anomalies induced by density heterogeneities are governed by Poisson's equation. Most existing methods for modelling such anomalies rely on its integral solution. In this approach, for each observation point, an integral over the entire density distribution needs to be carried out, and the computational cost is proportional to the number of observation points. Frequently, such methods are sensitive to high density contrasts due to inaccurate resolution of the volume integral. We introduce a new approach which directly solves a discretized form of the Poisson/Laplace equation. The main challenge in our approach involves the unbounded nature of the problem, because the potential exists in all of space. To circumvent this challenge, we combine a mapped infinite-element approach with a spectral-element method. Spectral elements represent the domain of interest, and a single layer of infinite elements captures outer space. To solve the weak form of the Poisson/Laplace equation, we use Gauss-Legendre- Lobatto (GLL) quadrature in spectral elements inside the domain of interest. Outside the domain, we use Gauss-Radau quadrature in the infinite direction, and GLL quadrature in the other directions. We illustrate the efficiency and accuracy of our method by comparing calculated gravity anomalies for various density heterogeneities with corresponding analytical solutions. Finally, we consider a complex 3-D model of an ore mine, which consists of both positive and negative density anomalies.