The chemical speciation of sulfur in heavy petroleums, petroleum source rock extracts, and source rock pyrolysis products was studied using X-ray absorption near-edge structure (XANES) spectroscopy. The good energy resolution (ca. 0.5 eV) at the sulfur K edge and the strong dependence of XANES on the sulfur environment combine to give excellent sensitivity to changes in the electronic and structural environment of the sulfur. This has permitted identification and approximate quantitation of different classes of sulfur-containing compounds (e.g., sulfur, sulfides (including disulfides and polysulfides as a group), thiophenes, sulfoxides, sulfones, sulfinic acids, sulfonic acids, and sulfate) in a series of petroleums and petroleum source rocks. Our results indicate that the sulfur speciation of geological samples can be correlated with differences in source depositional environment, thermal maturity, and aromaticity. We report organosulfur compositions for the asphaltene, maltene, and liquid chromatographic fractions of two sulfur-rich oils. In addition, we find that the organosulfur species in some, but not all, oils are subject to oxidation upon storage and thus may also be susceptible to oxidation in shallow reservoirs exposed to oxic waters. This work illustrates the utility of XANES as a direct spectroscopic probe for the quantitative determination of sulfur species in geological samples.