ABSTRACT An extinction-free estimator of the star formation rate (SFR) of galaxies is critical for understanding the high-redshift universe. To this end, the nearly linear, tight correlation of far-infrared (FIR), and radio luminosity of star-forming galaxies is widely used. While the FIR is linked to massive star formation, which also generates shock-accelerated cosmic-ray (CR) electrons and radio synchrotron emission, a detailed understanding of the underlying physics is still lacking. Hence, we perform three-dimensional magnetohydrodynamical (MHD) simulations of isolated galaxies over a broad range of halo masses and SFRs using the moving-mesh code arepo, and evolve the CR proton energy density self-consistently. In post-processing, we calculate the steady-state spectra of primary, shock-accelerated and secondary CR electrons, which result from hadronic CR proton interactions with the interstellar medium. The resulting total radio luminosities correlate with the FIR luminosities as observed and are dominated by primary CR electrons if we account for anisotropic CR diffusion. The increasing contribution of secondary emission up to 30 per cent in starbursts is compensated by the larger bremsstrahlung and Coulomb losses. CR electrons are in the calorimetric limit and lose most of their energy through inverse Compton interactions with star light and cosmic microwave background (CMB) photons while less energy is converted into synchrotron emission. This implies steep steady-state synchrotron spectra in starbursts. Interestingly, we find that thermal free–free emission flattens the total radio spectra at high radio frequencies and reconciles calorimetric theory with observations while free–free absorption explains the observed low-frequency flattening towards the central regions of starbursts.