Context. Radio continuum emission from galaxies at gigahertz frequencies can be used as an extinction-free tracer of star formation. However, at frequencies of a few hundred megahertz, there is evidence for low-frequency spectral flattening. Aims. We wish to understand the origin of this low-frequency flattening better, and to this end, we performed a spatially resolved study of the nearby spiral galaxy M51. We explored the different effects that can cause a flattening of the spectrum towards lower frequencies, such as free–free absorption and cosmic-ray ionisation losses. Methods. We used radio continuum intensity maps between 54 and 8350 MHz at eight different frequencies, with observations at 240 MHz from the Giant Metrewave Radio Telescope presented for the first time. We corrected for the contribution from thermal free–free emission using an H α map that was corrected for extinction with 24 μm data. We fitted free–free absorption models to the radio spectra to determine the emission measure (EM) as well as polynomial functions to measure the non-thermal spectral curvature. We also obtained a new extinction-corrected H α intensity map from the Metal-THINGS survey using integral field unit spectroscopy. Results. The non-thermal low-frequency radio continuum spectrum between 54 and 144 MHz is very flat and even partially inverted, particularly in the spiral arms; in contrast, the spectrum at higher frequencies is typical for a non-thermal radio continuum spectrum. However, we did not find any correlation between the EMs calculated from radio and from H α observations; instead, the non-thermal spectral curvature weakly correlates with the H I gas-mass surface density. This suggests that cosmic-ray ionisation losses play an important role in the low-frequency spectral flattening. Conclusions. The observed spectral flattening towards low frequencies in M51 is caused by a combination of ionisation losses and free–free absorption. The reasons for this flattening need to be understood in order to use sub-gigahertz frequencies as a tracer of star formation.