A new application has been developed, based on geostatistical techniques of cokriging and conditional simulation, for the 3D inversion of gravity data including geologic constraints. The necessary gravity, density, and gravity-density covariance matrices are estimated using the observed gravity data. Then the densities are cokriged or simulated using the gravity data as the secondary variable. The model allows noise to be included in the observations. The method is applied to two synthetic models: a short dipping dike and a stochastic distribution of densities. Then some geologic information is added as constraints to the cokriging system. The results show the ability of the method to integrate complex a priori information. The survey data of the Matagami mining camp are considered as a case study. The inversion method based on cokriging is applied to the residual anomaly to map the geology through the estimation of the density distribution in this region. The results of the inversion and simulation methods are in good agreement with the surface geology of the survey region.