A new method for inversion of potential fields is developed using a depth-weighting function specifically designed for fields related to complex source distributions. Such a weighting function is determined from an analysis of the field that precedes the inversion itself. The algorithm is self-consistent, meaning that the weighting used in the inversion is directly deduced from the scaling properties of the field. Hence, the algorithm is based on two steps: (1) estimation of the locally homogeneous degree of the field in a 3D domain of the harmonic region and (2) inversion of the data using a specific weighting function with a 3D variable exponent. A multiscale data set is first formed by upward continuation of the original data. Local homogeneity and a multihomogeneous model are then assumed, and a system built on the scaling function is solved at each point of the multiscale data set, yielding a multiscale set of local-homogeneity degrees of the field. Then, the estimated homogeneity degree is associated to the model weighting function in the source volume. Tests on synthetic data show that the generalization of the depth weighting to a 3D function and the proposed two-step algorithm has great potential to improve the quality of the solution. The gravity field of a polyhedron is inverted yielding a realistic reconstruction of the whole body, including the bottom surface. The inversion of the aeromagnetic real data set, from the Mt. Vulture area, also yields a good and geologically consistent reconstruction of the complex source distribution.