Our statistical understanding of galaxy evolution is fundamentally driven by objects that lie above the surface-brightness limits of current wide-area surveys (µ ∼ 23 mag arcsec −2 ). While both theory and small, deep surveys have hinted at a rich population of lowsurface-brightness galaxies (LSBGs) fainter than these limits, their formation remains poorly understood. We use Horizon-AGN, a cosmological hydrodynamical simulation to study how LSBGs, and in particular the population of ultra-diffuse galaxies (UDGs; µ > 24.5 mag arcsec −2 ), form and evolve over time. For M * >10 8 M , LSBGs contribute 47, 7 and 6 per cent of the local number, mass and luminosity densities respectively (∼85/11/10 per cent for M * >10 7 M ). Today's LSBGs have similar dark-matter fractions and angular momenta to high-surface-brightness galaxies (HSBGs; µ < 23 mag arcsec −2 ), but larger effective radii (×2.5 for UDGs) and lower fractions of dense, star-forming gas (more than ×6 less in UDGs than HSBGs). LSBGs originate from the same progenitors as HSBGs at z > 2. However, LSBG progenitors form stars more rapidly at early epochs. The higher resultant rate of supernova-energy injection flattens their gas-density profiles, which, in turn, creates shallower stellar profiles that are more susceptible to tidal processes. After z ∼ 1, tidal perturbations broaden LSBG stellar distributions and heat their cold gas, creating the diffuse, largely gas-poor LSBGs seen today. In clusters, ram-pressure stripping provides an additional mechanism that assists in gas removal in LSBG progenitors. Our results offer insights into the formation of a galaxy population that is central to a complete understanding of galaxy evolution, and which will be a key topic of research using new and forthcoming deep-wide surveys.