Thermal leptogenesis, in the framework of the standard model with three additional heavy Majorana neutrinos, provides an attractive scenario to explain the observed baryon asymmetry in the universe. It is based on the out-of-equilibrium decay of Majorana neutrinos in a thermal bath of standard model particles, which in a fully quantum field theoretical formalism is obtained by solving Kadanoff-Baym equations. So far, the leading two-loop contributions from leptons and Higgs particles are included, but not yet gauge corrections. These enter at three-loop level but, in certain kinematical regimes, require a resummation to infinite loop order for a result to leading order in the gauge coupling. In this work, we apply such a resummation to the calculation of the lepton number density. The full result for the simplest vanilla leptogenesis scenario is by $mathcal{O}(1)$ increased compared to that of quantum Boltzmann equations, and for the first time permits an estimate of all theoretical uncertainties. This step completes the quantum theory of leptogenesis and forms the basis for quantitative evaluations, as well as extensions to other scenarios.