We consider QCD radiative corrections to the production of colorless high-mass systems in hadron collisions. The logarithmically-enhanced contributions at small transverse momentum are treated to all perturbative orders by a universal resummation formula that depends on a single process-dependent hard factor. We show that the hard factor is directly related to the all-order virtual amplitude of the corresponding partonic process. The direct relation is universal (process-independent), and it is expressed by an all-order factorization formula that we explicitly evaluate up to the next-to-next-to-leading order (NNLO) in QCD perturbation theory. Once the NNLO scattering amplitude is available, the corresponding hard factor is directly determined: it controls NNLO contributions in resummed calculations at full next-to-next-to-leading logarithmic accuracy, and it can be used in applications of the qT subtraction formalism to perform fully-exclusive perturbative calculations up to NNLO. The universality structure of the hard factor and its explicit NNLO form are also extended to the related formalism of threshold resummation.