We have developed a novel approach for inversion of gravity and gravity gradiometry data based on multinary transformation of the model parameters. This concept is a generalization of binary density inversion to the models described by any number of discrete model parameters. The multinary inversion makes it possible to explicitly exploit the sharp contrasts of the density between the host media and anomalous targets in the inversion of gravity and gravity gradiometry data. In the framework of the multinary inversion method, we use the given values of density and error functions to transform the density distribution into the desired step-function distribution. To accommodate a possible deviation of the densities from the fixed discrete values, we develop an adaptive technique for selecting the corresponding standard deviations, guided by the inversion process. The novel adaptive multinary inversion algorithm is demonstrated to be effective in determining the shape, location, and densities of the anomalous targets. We find that this method can be effectively applied for the inversion of the full tensor gravity gradiometry (FTG) data computer simulated for the SEG salt density model and for the field FTG data collected in the Nordkapp Basin, Barents Sea.