At hadron colliders, the leading production mechanism for a pair of photons is from quark-anti-quark annihilation at the tree level. However, due to large gluon-gluon luminosity, the loop-induced process $gg\to \gamma \gamma$ provides a substantial contribution. In particular, the amplitudes mediated by the top quark become important at the $t \bar t$ threshold and above. In this letter we present the first complete computation of the next-to-leading order (NLO) corrections (up to $\alpha_S^3$) to this process, including contributions from the top quark. These entail two-loop diagrams with massive propagators whose analytic expressions are unknown and have been evaluated numerically. We find that the NLO corrections to the top-quark induced terms are very large at low diphoton invariant mass $m(\gamma \gamma)$ and close to the $t \bar t$ threshold. The full result including five massless quarks and top quark contributions at NLO displays a much more pronounced change of slope in the $m(\gamma \gamma)$ distribution at $t \bar t$ threshold than at LO and an enhancement at high invariant mass with respect to the massless calculation.