A method for solving the inverse variational problem for differential equations admitting a Lie group is presented. The method is used for determining invariant Lagrangians and integration of second-order nonlinear differential equations admitting two-dimensional non-commutative Lie algebras. The method of integration suggested here is different from Lie's classical method of integration of second-order ordinary differential equations based on canonical forms of two-dimensional Lie algebras. The new method reveals existence and significance of one-parameter families of singular solutions to nonlinear equations of second order.