Sulfur K-edge XANES (X-ray absorption near-edge structure) spectroscopy is an excellent tool for determining the speciation of sulfur compounds in complex matrices. This paper presents a method to quantitatively determine the kinds of sulfur species in natural samples using internally calibrated reference spectra of model compounds. Owing to significant self-absorption of formed fluorescence radiation in the sample itself the fluorescence signal displays a non-linear correlation with the sulfur content over a wide concentration range. Self-absorption is also a problem at low total absorption of the sample when the sulfur compounds are present as particles. The post-edge intensity patterns of the sulfur K-edge XANES spectra vary with the type of sulfur compound, with reducing sulfur compounds often having a higher post-edge intensity than the oxidized forms. In dilute solutions (less than 0.3-0.5%) it is possible to use sulfur K-edge XANES reference data for quantitative analysis of the contribution from different species. The results show that it is essential to use an internal calibration system when performing quantitative XANES analysis. Preparation of unknown samples must take both the total absorption and possible presence of self-absorbing particles into consideration.