The structure of static MHD equilibria that admit continuous families of Euclidean symmetries is well understood. Such field configurations are governed by the classical Grad-Shafranov equation, which is a single elliptic PDE in two space dimensions. By revealing a hidden symmetry, we show that in fact all smooth solutions of the equilibrium equations with non-vanishing pressure gradients away from the magnetic axis satisfy a generalization of the Grad-Shafranov equation. In contrast to solutions of the classical Grad-Shafranov equation, solutions of he generalized equation are not automatically equilibria, but instead only satisfy force balance averaged over the one-parameter hidden symmetry. We then explain how the generalized Grad-Shafranov equation can be used to reformulate the problem of finding exact three-dimensional smooth solutions of the equilibrium equations as finding an optimal volume-preserving symmetry.