We compute the QCD corrections at next-to-leading order for the process gg → ZH, including both the virtual two-loop terms and real-emission contributions. The two-loop box diagrams in the virtual corrections are approximated analytically over the complete phase space, combining the results of an expansion in the limit of small transverse momentum and an expansion in the regime of high energy. We obtain both inclusive and differential results for the cross section. We find that the NLO QCD corrections are of the same size as the LO contribution up to ZH invariant masses close to 1 TeV, but they increase significantly when higher energies are considered, due to a class of real-emission diagrams in which the Z boson is radiated from an open quark line. Finally, we estimate the uncertainty due to the renormalization scheme used for the top-quark mass both on the total and differential cross section.