We consider the production of a Standard-Model (SM) Higgs boson in gluon fusion in hadronic collisions and compute the QCD corrections up to next-to-next-to-leading order (NNLO) and match them to parton showers (NNLO+PS). The complete dependence on the top-quark mass is taken into account without making any approximations to the top quark loops mediating the coupling between the gluons and the Higgs boson. To this end, we have included the gg→H amplitudes up to three loops and the pp→H+jet amplitudes up to two loops in the full SM theory. This is the first fully differential calculation of the top-quark mass effects up to NNLO in QCD, and we study their impact on relevant observables for the LHC.