Equivalence of the Hamiltonian and Lagrangian path integrals for gauge theories