The near-threshold n p -> d pi0 cross section is calculated in chiral perturbation theory to next-to-leading order in the expansion parameter sqrt{M m_pi}/Lambda_chi. At this order irreducible pion loops contribute to the relevant pion-production operator. While their contribution to this operator is finite, considering initial-and final-state distortions produces a linear divergence in its matrix elements. We renormalize this divergence by introducing a counterterm, whose value we choose in order to reproduce the threshold n p -> d pi0 cross section measured at TRIUMF. The energy-dependence of this cross section is then predicted in chiral perturbation theory, being determined by the production of p-wave pions, and also by energy dependence in the amplitude for the production of s-wave pions. With an appropriate choice of the counterterm, the chiral prediction for this energy dependence converges well.