Finite dimensional linear and nonlinear least-squares problems appear in data fitting and the solution of nonlinear equations. In this talk I will present some recent results for the infinite dimensional analogs of such problems. They include (i) a general framework for solving distributed elliptic optimal control problems with pointwise state constraints by finite element methods originally designed for fourth order elliptic boundary value problems, (ii) a multiscale finite element method for solving distributed elliptic optimal control problems with rough coefficients and pointwise control constraints, and (iii) a convexity enforcing nonlinear least-squares finite element method for solving the Monge-Ampere equation.