Owing to its low excitation energy and long radiative lifetime, the first excited isomeric state of thorium-229, 229mTh, can be optically controlled by a laser1,2 and is an ideal candidate for the creation of a nuclear optical clock3, which is expected to complement and outperform current electronic-shell-based atomic clocks4. A nuclear clock will have various applications-such as in relativistic geodesy5, dark matter research6 and the observation of potential temporal variations of fundamental constants7-but its development has so far been impeded by the imprecise knowledge of the energy of 229mTh. Here we report a direct measurement of the transition energy of this isomeric state to the ground state with an uncertainty of 0.17 electronvolts (one standard deviation) using spectroscopy of the internal conversion electrons emitted in flight during the decay of neutral 229mTh atoms. The energy of the transition between the ground state and the first excited state corresponds to a wavelength of 149.7 ± 3.1 nanometres, which is accessible by laser spectroscopy through high-harmonic generation. Our method combines nuclear and atomic physics measurements to advance precision metrology, and our findings are expected to facilitate the application of high-resolution laser spectroscopy on nuclei and to enable the development of a nuclear optical clock of unprecedented accuracy.