The cosmic radio-frequency spectrum is expected to show a strong absorption signal corresponding to the 21-centimetre-wavelength transition of atomic hydrogen around redshift 20, which arises from Lyman-alpha radiation from some of the earliest stars. By observing this 21-centimetre signal - either its sky-averaged spectrum or maps of its fluctuations, obtained using radio interferometers - we can obtain information about cosmic dawn, the era when the first astrophysical sources of light were formed. The recent detection of the global 21-centimetre spectrum reveals a stronger absorption than the maximum predicted by existing models, at a confidence level of 3.8 standard deviations. Here we report that this absorption can be explained by the combination of radiation from the first stars and excess cooling of the cosmic gas induced by its interaction with dark matter. Our analysis indicates that the spatial fluctuations of the 21-centimetre signal at cosmic dawn could be an order of magnitude larger than previously expected and that the dark-matter particle is no heavier than several proton masses, well below the commonly predicted mass of weakly interacting massive particles. Our analysis also confirms that dark matter is highly non-relativistic and at least moderately cold, and primordial velocities predicted by models of warm dark matter are potentially detectable. These results indicate that 21-centimetre cosmology can be used as a dark-matter probe.