In this paper we present the theorem on Lie integrability by quadratures for time-independent Hamiltonian systems on symplectic and contact manifolds, and for time-dependent Hamiltonian systems on cosymplectic and cocontact manifolds. We show that having a solvable Lie algebra of constants of motion for a Hamiltonian system is equivalent to having a solvable Lie algebra of symmetries of the vector field defining the dynamics of the system, which allows us to find the solutions of the equations of motion by quadratures.