Understanding the composition of the atmosphere over geological time is critical to understanding the history of the Earth system, as the atmosphere is closely linked to the lithosphere, hydrosphere and biosphere. Although much of the history of the lithosphere and hydrosphere is contained in rock and mineral records, corresponding information about the atmosphere is scarce and elusive owing to the lack of direct records. Geologists have used sedimentary minerals, fossils and geochemical models to place constraints on the concentrations of carbon dioxide, oxygen or methane in the past. Here we show that the triple oxygen isotope composition of sulphate from ancient evaporites and barites shows variable negative oxygen-17 isotope anomalies over the past 750 million years. We propose that these anomalies track those of atmospheric oxygen and in turn reflect the partial pressure of carbon dioxide (P(CO2)) in the past through a photochemical reaction network linking stratospheric ozone to carbon dioxide and to oxygen. Our results suggest that P(CO2) was much higher in the early Cambrian than in younger eras, agreeing with previous modelling results. We also find that the (17)O isotope anomalies of barites from Marinoan (approximately 635 million years ago) cap carbonates display a distinct negative spike (around -0.70 per thousand), suggesting that by the time barite was precipitating in the immediate aftermath of a Neoproterozoic global glaciation, the P(CO2) was at its highest level in the past 750 million years. Our finding is consistent with the 'snowball Earth' hypothesis and/or a massive methane release after the Marinoan glaciation.