The photoelectric effect is not truly instantaneous but exhibits attosecond delays that can reveal complex molecular dynamics1-7. Sub-femtosecond-duration light pulses provide the requisite tools to resolve the dynamics of photoionization8-12. Accordingly, the past decade has produced a large volume of work on photoionization delays following single-photon absorption of an extreme ultraviolet photon. However, the measurement of time-resolved core-level photoionization remained out of reach. The required X-ray photon energies needed for core-level photoionization were not available with attosecond tabletop sources. Here we report measurements of the X-ray photoemission delay of core-level electrons, with unexpectedly large delays, ranging up to 700 as in NO near the oxygen K-shell threshold. These measurements exploit attosecond soft X-ray pulses from a free-electron laser to scan across the entire region near the K-shell threshold. Furthermore, we find that the delay spectrum is richly modulated, suggesting several contributions, including transient trapping of the photoelectron owing to shape resonances, collisions with the Auger-Meitner electron that is emitted in the rapid non-radiative relaxation of the molecule and multi-electron scattering effects. The results demonstrate how X-ray attosecond experiments, supported by comprehensive theoretical modelling, can unravel the complex correlated dynamics of core-level photoionization.