We show explicitly that the well-known Gouy phase shift of any focused beam originates from transverse spatial confinement, which, through the uncertainty principle, introduces a spread in the transverse momenta and hence a shift in the expectation value of the axial propagation constant. A general expression is given for the Gouy phase shift in terms of expectation values of the squares of the transverse momenta. Our result also explains the phase shift in front of the Kirchhoff diffraction integral.