We solve the problem of describing all nonsingular pairs of compatible flat metrics (or, in other words, nonsingular flat pencils of metrics) in the general N-component case. This problem is equivalent to the problem of describing all compatible Dubrovin–Novikov brackets (compatible nondegenerate local Poisson brackets of hydrodynamic type) playing an important role in the theory of integrable systems of hydrodynamic type and also in modern differential geometry and field theory. We prove that all nonsingular pairs of compatible flat metrics are described by a system of nonlinear differential equations that is a special nonlinear differential reduction of the classical Lame equations, and we present a scheme for integrating this system by the method of the inverse scattering problem. The integration procedure is based on using the Zakharov method for integrating the Lame equations (a version of the inverse scattering method).