This paper presents a novel Hamiltonian formulation of the isotropic Navier–Stokes problem based on a minimum-action principle derived from the principle of least squares. This formulation uses the velocities $u_{i}(x_{j},t)$ and pressure $p(x_{j},t)$ as the field quantities to be varied, along with canonically conjugate momenta deduced from the analysis. From these, a conserved Hamiltonian functional $H^{*}$ satisfying Hamilton's canonical equations is constructed, and the associated Hamilton–Jacobi equation is formulated for both compressible and incompressible flows. This Hamilton–Jacobi equation reduces the problem of finding four separate field quantities ( $u_{i}$ , $p$ ) to that of finding a single scalar functional in those fields – Hamilton's principal functional ${S}^{*}[u_{i},p,t]$ . Moreover, the transformation theory of Hamilton and Jacobi now provides a prescribed recipe for solving the Navier–Stokes problem: find ${S}^{*}$ . If an analytical expression for ${S}^{*}$ can be obtained, it will lead via canonical transformation to a new set of fields which are simply equal to their initial values, giving analytical expressions for the original velocity and pressure fields. Failing that, if one can only show that a complete solution to this Hamilton–Jacobi equation does or does not exist, that will also resolve the question of existence of solutions. The method employed here is not specific to the Navier–Stokes problem or even to classical mechanics, and can be applied to any traditionally non-Hamiltonian problem.