Stratospheric ozone screens the Earth’s surface from harmful ultraviolet-B radiation. Concentrations of stratospheric ozone are governed by a variety of natural and anthropogenic factors, including solar cycles1, volcanic aerosols2, ozone-depleting substances3 and climate change4. However, assessing this variability before instrumental records has proved difficult owing to the lack of a well-constrained proxy5. Here, we use microspectroscopy to analyse the chemical composition of herbarium samples of clubmoss (Lycophyta) spores originating from high- and low-latitude localities, where they were exposed to different ultraviolet-B histories. We show that the concentration of two ultraviolet-B-absorbing compounds in the walls of high-northern- and southern-latitude spores is strongly regulated by historical variations in ultraviolet-B radiation. Conversely, we find little change in the concentration of these compounds in spores originating from tropical Ecuador, where ultraviolet levels have remained relatively stable. Using spores from Greenland, we reconstruct past (1907–1993) changes in ozone concentration and ultraviolet-B flux; we reveal strong similarities between spore-wall reconstructions, and independent instrumental records6 and model results7. Our findings suggest that ultraviolet-B-absorbing compounds in plant spore walls have the potential to act as a proxy for past changes in terrestrial ultraviolet-B radiation and stratospheric ozone. The chemical signature of plant spore walls in herbaria, and possibly also in sedimentary and ice-core archives, may therefore prove valuable for reconstructing past variations in stratospheric ozone and their connections with changes in solar radiation and climate.