Magnetically doped topological insulators enable the quantum anomalous Hall effect (QAHE), which provides quantized edge states for lossless charge-transport applications 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 . The edge states are hosted by a magnetic energy gap at the Dirac point 2 , but hitherto all attempts to observe this gap directly have been unsuccessful. Observing the gap is considered to be essential to overcoming the limitations of the QAHE, which so far occurs only at temperatures that are one to two orders of magnitude below the ferromagnetic Curie temperature, T C (ref. 8 ). Here we use low-temperature photoelectron spectroscopy to unambiguously reveal the magnetic gap of Mn-doped Bi 2 Te 3 , which displays ferromagnetic out-of-plane spin texture and opens up only below T C . Surprisingly, our analysis reveals large gap sizes at 1 kelvin of up to 90 millielectronvolts, which is five times larger than theoretically predicted 9 . Using multiscale analysis we show that this enhancement is due to a remarkable structure modification induced by Mn doping: instead of a disordered impurity system, a self-organized alternating sequence of MnBi 2 Te 4 septuple and Bi 2 Te 3 quintuple layers is formed. This enhances the wavefunction overlap and size of the magnetic gap 10 . Mn-doped Bi 2 Se 3 (ref. 11 ) and Mn-doped Sb 2 Te 3 form similar heterostructures, but for Bi 2 Se 3 only a nonmagnetic gap is formed and the magnetization is in the surface plane. This is explained by the smaller spin–orbit interaction by comparison with Mn-doped Bi 2 Te 3 . Our findings provide insights that will be crucial in pushing lossless transport in topological insulators towards room-temperature applications.