We consider the transverse-momentum (q_T) distribution of Standard Model Higgs bosons produced by gluon fusion in hadron collisions. At small q_T (q_T<<m_H, m_H being the mass of the Higgs boson), we resum the logarithmically-enhanced contributions due to multiple soft-gluon emission to all order in QCD perturbation theory. At intermediate and large values of q_T (q_T <~m_H), we consistently combine resummation with the known fixed-order results. We use the most advanced perturbative information that is available at present: next-to-next-to-leading logarithmic resummation combined with the next-to-leading fixed-order calculation. We extend previous results including exactly all the perturbative terms up to order alphas^4 in our computation and, after integration over q_T, we recover the known next-to-next-to-leading order result for the total cross section. We present numerical results at the Tevatron and the LHC, together with an estimate of the corresponding uncertainties. Our calculation is implemented in an updated version of the numerical code HqT.