This work starts with classical equations of motion and sets very general quantization conditions (commutation relations). It is proved that these conditions imply that the equations of motion are equivalent to the Euler-Lagrange equations of a Lagrangian L. The result is a generalization of work by Feynman, recently reported by Dyson [Am. J. Phys. 58, 209-211 (1990)]. The Lagrangian L need not be unique. Examples are given, including classical equations that do not come from a Lagrangian and therefore cannot be quantized consistently.