Sulfur in crude oil comes generally from the decomposition of organic matter, and with the passage of time and of gradual settling into strata, the sulfur segregates from crude oil in the form of hydrogen sulfide that appears in the associated gas, some portion of sulfur stays with the liquid. Another theory behind origin of sulfur compounds is the reduction of sulfates by hydrogen by bacterial action of the type desulforibrio desulfuricans:


Hydrogen comes from the reservoir fluid and the sulfate ions are kept in the reservoir rock, as a result hydrogen sulfide is generated. The H2S formed can react with the sulfates or rock to form sulfur that remains in composition of crude as in the case of oil from Goldsmith, Texas, USA. Moreover, under the conditions of pressure, temperature and period of formation of the reservoir H2S can react with the hydrocarbons to give sulfur compounds.
Sulfur compounds are among the most important non-hydrocarbon heteroatomic constituents of petroleum. There are significant amount of sulfur species found in crude oil and sulfur compounds of one type or another are present in all crude oils. Furthermore, only preferred type of sulfur exist in any particular crude oil, and this is dictated by the prevailing conditions during the formation, maturation, and even in situ alteration.
In general, the higher the density of the crude oil, the lower the API gravity of the crude and the higher the sulfur content. The total sulfur in crude oil can vary from 0.04% w/w for light crude oil to about 5% w/w for heavy crude oil and tar sand bitumen. Nevertheless, the sulfur content of crude oils which is produced from different locations varies with time, depending on the chemical composition of newly discovered fields, especially those in different geological environments.