Three conditions must be present for oil reservoirs to form: a source rock rich in hydrocarbon material buried deep enough for subterranean heat to cook it into oil; a porous and permeable reservoir rock for it to accumulate in; and a cap rock (seal) or other mechanism that prevents it from escaping to the surface. Within these reservoirs, fluids will typically organize themselves like a three-layer cake with a layer of water below the oil layer and a layer of gas above it, although the different layers vary in size between reservoirs. Because most hydrocarbons are lighter than rock or water, they often migrate upward through adjacent rock layers until either reaching the surface or becoming trapped within porous rocks (known as reservoirs) by impermeable rocks above. However, the process is influenced by underground water flows, causing oil to migrate hundreds of kilometres horizontally or even short distances downward before becoming trapped in a reservoir. When hydrocarbons are concentrated in a trap, an oil field forms, from which the liquid can be extracted by drilling and pumping.
The reactions that produce oil and natural gas are often modeled as first order breakdown reactions, where hydrocarbons are broken down to oil and natural gas by a set of parallel reactions, and oil eventually breaks down to natural gas by another set of reactions. The latter set is regularly used in petrochemical plants and oil refineries.
Wells are drilled into oil reservoirs to extract the crude oil. "Natural lift" production methods that rely on the natural reservoir pressure to force the oil to the surface are usually sufficient for a while after reservoirs are first tapped. In some reservoirs, such as in the Middle East, the natural pressure is sufficient over a long time. The natural pressure in many reservoirs, however, eventually dissipates. Then the oil must be pumped out using “artificial lift” created by mechanical pumps powered by gas or electricity. Over time, these "primary" methods become less effective and "secondary" production methods may be used. A common secondary method is “waterflood” or injection of water into the reservoir to increase pressure and force the oil to the drilled shaft or "wellbore." Eventually "tertiary" or "enhanced" oil recovery methods may be used to increase the oil's flow characteristics by injecting steam, carbon dioxide and other gases or chemicals into the reservoir. In the United States, primary production methods account for less than 40% of the oil produced on a daily basis, secondary methods account for about half, and tertiary recovery the remaining 10%. Extracting oil (or “bitumen”) from oil/tar sand and oil shale deposits requires mining the sand or shale and heating it in a vessel or retort, or using “in-situ” methods of injecting heated liquids into the deposit and then pumping out the oil-saturated liquid.
Oil-eating bacteria biodegrade oil that has escaped to the surface. Oil sands are reservoirs of partially biodegraded oil still in the process of escaping and being biodegraded, but they contain so much migrating oil that, although most of it has escaped, vast amounts are still present—more than can be found in conventional oil reservoirs. The lighter fractions of the crude oil are destroyed first, resulting in reservoirs containing an extremely heavy form of crude oil, called crude bitumen in Canada, or extra-heavy crude oil in Venezuela. These two countries have the world's largest deposits of oil sands.
On the other hand, oil shales are source rocks that have not been exposed to heat or pressure long enough to convert their trapped hydrocarbons into crude oil. Technically speaking, oil shales are not always shales and do not contain oil, but are fined-grain sedimentary rocks containing an insoluble organic solid called kerogen. The kerogen in the rock can be converted into crude oil using heat and pressure to simulate natural processes. The method has been known for centuries and was patented in 1694 under British Crown Patent No. 330 covering, "A way to extract and make great quantityes of pitch, tarr, and oyle out of a sort of stone." Although oil shales are found in many countries, the United States has the world's largest deposits.
The petroleum industry generally classifies crude oil by the geographic location it is produced in (e.g. West Texas Intermediate, Brent, or Oman), its API gravity (an oil industry measure of density), and its sulfur content. Crude oil may be considered light if it has low density or heavy if it has high density; and it may be referred to as sweet if it contains relatively little sulfur or sour if it contains substantial amounts of sulfur.
The geographic location is important because it affects transportation costs to the refinery. Light crude oil is more desirable than heavy oil since it produces a higher yield of petrol, while sweet oil commands a higher price than sour oil because it has fewer environmental problems and requires less refining to meet sulfur standards imposed on fuels in consuming countries. Each crude oil has unique molecular characteristics which are understood by the use of crude oil assay analysis in petroleum laboratories.
Barrels from an area in which the crude oil's molecular characteristics have been determined and the oil has been classified are used as pricing references throughout the world. Some of the common reference crudes are:
- West Texas Intermediate (WTI), a very high-quality, sweet, light oil delivered at Cushing, Oklahoma for North American oil
- Brent Blend, comprising 15 oils from fields in the Brent and Ninian systems in the East Shetland Basin of the North Sea. The oil is landed at Sullom Voe terminal in Shetland. Oil production from Europe, Africa and Middle Eastern oil flowing West tends to be priced off this oil, which forms a benchmark
- Dubai-Oman, used as benchmark for Middle East sour crude oil flowing to the Asia-Pacific region
- Tapis (from Malaysia, used as a reference for light Far East oil)
- Minas (from Indonesia, used as a reference for heavy Far East oil)
- The OPEC Reference Basket, a weighted average of oil blends from various OPEC (The Organization of the Petroleum Exporting Countries) countries
- Midway Sunset Heavy, by which heavy oil in California is priced
There are declining amounts of these benchmark oils being produced each year, so other oils are more commonly what is actually delivered. While the reference price may be for West Texas Intermediate delivered at Cushing, the actual oil being traded may be a discounted Canadian heavy oil delivered at Hardisty, Alberta, and for a Brent Blend delivered at Shetland, it may be a Russian Export Blend delivered at the port of Primorsk.
Crude oil and refined fuel spills from tanker ship accidents have damaged natural ecosystems in Alaska, the Gulf of Mexico, the Galapagos Islands, France and many other places.
The quantity of oil spilled during accidents has ranged from a few hundred tons to several hundred thousand tons (e.g., Deepwater Horizon Oil Spill, Atlantic Empress, Amoco Cadiz). Smaller spills have already proven to have a great impact on ecosystems, such as the Exxon Valdez oil spill
Oil spills at sea are generally much more damaging than those on land, since they can spread for hundreds of nautical miles in a thin oil slick which can cover beaches with a thin coating of oil. This can kill sea birds, mammals, shellfish and other organisms it coats. Oil spills on land are more readily containable if a makeshift earth dam can be rapidly bulldozed around the spill site before most of the oil escapes, and land animals can avoid the oil more easily.
Control of oil spills is difficult, requires ad hoc methods, and often a large amount of manpower. The dropping of bombs and incendiary devices from aircraft on the Torrey Canyon wreck produced poor results; modern techniques would include pumping the oil from the wreck, like in the Prestige oil spill or the Erika oil spill.
Though crude oil is predominantly composed of various hydrocarbons, certain nitrogen heterocylic compounds, such as pyridine, picoline, and quinoline are reported as contaminants associated with crude oil, as well as facilities processing oil shale or coal, and have also been found at legacy wood treatment sites. These compounds have a very high water solubility, and thus tend to dissolve and move with water. Certain naturally occurring bacteria, such as Micrococcus, Arthrobacter, and Rhodococcus and have been shown to degrade these contaminants.