Even though the dark-matter power spectrum in the absence of biasing predicts a number density of haloes n(M) ∝M−2 (i.e. a Schechter α value of −2) at the low-mass end (M < 1010 M⊙), hydrodynamic simulations have typically produced values for stellar systems in good agreement with the observed value α≃−1. We explain this with a simple physical argument and show that an efficient external gas-heating mechanism (such as the UV background included in all hydro codes) will produce a critical halo mass below which haloes cannot retain their gas and form stars. We test this conclusion with gadget-2-based simulations using various UV backgrounds, and for the first time we also investigate the effect of an X-ray background. We show that at the present epoch α depends primarily on the mean gas temperature at the star-formation epoch for low-mass systems (z≲ 3): with no background we find α≃−1.5, with UV only α≃−1.0 and with UV and X-rays α≃−0.75. We find the critical final halo mass for star formation to be ∼4 × 108 M⊙ with a UV background and ∼7 × 108 M⊙ with UV and X-rays.