We consider the problem of approximating the unknown density u ∈ L2 (Ω, λ) of a measure μ on Ω ⊂ ℝ2, absolutely continuous with respect to some given reference measure λ, only from the knowledge of finitely many moments of μ. Given d ∈ ℕ and moments of order d, we provide a polynomial p d which minimizes the mean square error ∫ (u - p) 2d λ over all polynomials p of degree at most d. If there is no additional requirement, p d is obtained as solution of a linear system. In addition, if p d is expressed in the basis of polynomials that are orthonormal with respect to λ, its vector of coefficients is just the vector of given moments and no computation is needed. Moreover pd → u in L2 (Ω, λ) as d → ∞. In general nonnegativity of p d is not guaranteed even though u is nonnegative. However, with this additional nonnegativity requirement one obtains analogous results but computing pd ≥ 0 that minimizes ∫ (u - p) O d λ now requires solving an appropriate semidefinite program. We have tested the approach on some applications arising from the reconstruction of geometrical objects and the approximation of solutions of nonlinear differential equations. In all cases our results are significantly better than those obtained with the maximum entropy technique for estimating u. © 2014 Springer Science+Business Media New York.