Petroleum is a fossil fuel derived from ancient fossilized organic materials, such as zooplankton and algae. Vast quantities of these remains settled to sea or lake bottoms, mixing with sediments and being buried under anoxic conditions. As further layers settled to the sea or lake bed, intense heat and pressure build up in the lower regions. This process caused the organic matter to change, first into a waxy material known as kerogen, which is found in various oil shales around the world, and then with more heat into liquid and gaseous hydrocarbons via a process known as catagenesis. Formation of petroleum occurs from hydrocarbon pyrolysis in a variety of mainly endothermic reactions at high temperature and/or pressure.
There were certain warm nutrient-rich environments such as the Gulf of Mexico and the ancient Tethys Sea where the large amounts of organic material falling to the ocean floor exceeded the rate at which it could decompose. This resulted in large masses of organic material being buried under subsequent deposits such as shale formed from mud. This massive organic deposit later became heated and transformed under pressure into oil.
Geologists often refer to the temperature range in which oil forms as an "oil window" —below the minimum temperature oil remains trapped in the form of kerogen, and above the maximum temperature the oil is converted to natural gas through the process of thermal cracking. Sometimes, oil formed at extreme depths may migrate and become trapped at a much shallower level. The Athabasca Oil Sands are one example of this.
An alternative mechanism was proposed by Russian scientists in the mid-1850s, the Abiogenic petroleum origin, but this is contradicted by the geological and geochemical evidence.