Fossil fuels come from the remains of ancient living organisms, primarily plants and marine plankton, that were buried under layers of sediment millions of years ago. Cut off from oxygen, this organic material was slowly transformed by heat and pressure into coal, oil, and natural gas. The process took tens to hundreds of millions of years, and the specific type of fuel that formed depended on what kind of organism was buried, where it was buried, and how deep it ended up.
Coal Comes From Ancient Swamp Forests
Coal started as trees and other vegetation growing in vast coastal wetlands during the Carboniferous period, roughly 360 to 300 million years ago. These forests were dominated by giant relatives of modern club mosses, ferns, horsetails, and early seed plants. Many of these trees grew over 30 meters tall in swampy environments where standing water covered the forest floor.
When these plants died, they fell into waterlogged ground where oxygen was scarce. Normally, dead plant material decomposes quickly when exposed to air. But in these stagnant swamps, microorganisms could only partially break down the organic matter because they lacked oxygen to finish the job. The partially decomposed plant material accumulated as thick layers of peat. Over millions of years, new sediment piled on top, burying the peat deeper and deeper. The increasing weight compressed it, squeezed out water, and concentrated the carbon. Heat from the Earth’s interior accelerated the transformation. Peat became lignite (a soft, brownish coal), then bituminous coal, and eventually anthracite, the hardest and most carbon-dense form.
Oil and Gas Start With Microscopic Marine Life
Petroleum and natural gas trace back to a very different source: tiny marine organisms, primarily plankton, that lived in ancient oceans. When these organisms died, most of their remains were consumed by other creatures or decomposed in the water column. But in certain stagnant underwater environments where oxygen was depleted near the seafloor, abundant plankton remains accumulated alongside fine mud and silt.
Marine plankton are the major component in crude oil formation. As layers of sediment buried this organic-rich mud, it compacted into dark shale, often called source rock. The organic material trapped within it gradually transformed into a waxy substance called kerogen, an intermediate stage between biological matter and usable hydrocarbons. Around 80 to 90 percent of the oil in Earth’s crust formed through the thermal breakdown of this kerogen, while a smaller fraction (10 to 20 percent) came more directly from hydrocarbons that the organisms produced while alive.
Heat and Pressure Do the Heavy Lifting
Burial alone doesn’t create oil or gas. The source rock has to reach specific temperatures before kerogen breaks apart into liquid and gaseous hydrocarbons. Geologists call this temperature range the “oil window.” Laboratory experiments on kerogen-rich rock show that the critical transformation happens between about 300°C and 375°C. At the lower end of that range, kerogen converts primarily into oil. Push temperatures above 375°C to 400°C, and the kerogen passes through the oil window into the “gas window,” where natural gas becomes the dominant product.
In nature, reaching these temperatures requires burial to depths of several kilometers over millions of years. The deeper the source rock sinks, the hotter it gets from Earth’s internal heat. Pressure from the overlying rock also plays a role, though at the extreme conditions found deep underground, temperature matters more than pressure for driving the chemical reactions. This is why oil and gas deposits aren’t found everywhere there was once an ancient ocean. The organic-rich rock had to be buried to just the right depth for just the right amount of time.
How Oil and Gas Move to Where We Find Them
Here’s something that surprises most people: oil and gas are almost never extracted from the same rock where they formed. The source rocks, typically dense shales and clays, are so impermeable that fluids have a hard time flowing through them. Yet somehow, hydrocarbons end up in porous reservoir rocks like sandstones and limestones, sometimes far from their point of origin. Geologists call this the “migration paradox.”
The best explanation involves a two-stage journey. In the first stage, called primary migration, hydrocarbons escape from the source rock. As the source rock is squeezed by burial, pressure builds until tiny fractures open, releasing bursts of fluid. Oil may also dissolve into hot water trapped in the rock and get carried out during compaction, or natural gas mixed into the oil can reduce its thickness enough for it to seep through narrow pore spaces.
Once hydrocarbons reach more permeable rock, the second stage begins. Oil and gas are lighter than the water that fills the pore spaces in underground rock, so they rise buoyantly through the reservoir rock until something stops them. That something is a trap: an impermeable layer of rock, often shaped like an upside-down bowl, that catches the rising fluids. Inside these traps, the fluids sort themselves by density. Water settles to the bottom, oil floats above it, and gas collects at the top. These traps are what drilling targets.
Natural Gas Has Two Different Origins
Not all natural gas forms the same way. Thermogenic gas is the type described above, created by intense heat breaking down kerogen deep underground. It forms at temperatures between roughly 157°C and 221°C in geological settings. But there’s a second type, biogenic gas, that forms at much lower temperatures (below 50°C) through a completely different process.
Biogenic gas is produced by microorganisms that break down organic matter in oxygen-free environments, essentially the same anaerobic digestion process that happens in swamps, landfills, and even animal guts. Bacteria consume buried organic material and release methane as a byproduct. This process doesn’t require deep burial or millions of years. It happens relatively close to the surface wherever organic material is sealed off from oxygen. Some of the world’s shallow natural gas fields are biogenic in origin.
Methane Hydrates on the Ocean Floor
There’s a lesser-known form of fossil fuel locked in ocean sediments: methane hydrates. These are ice-like crystals where water molecules form a cage structure that traps methane inside. They exist in a narrow zone of the seafloor, starting at depths of about 250 meters in southern latitudes and 530 meters in northern latitudes, where temperatures are cold enough and pressure is high enough to keep the crystals stable.
The methane in these hydrates comes from bacteria decomposing carbon-rich organic sediments buried in marine layers. Deep bacterial activity provides a steady supply of nearly pure methane gas that rises through the sediment. As this gas enters colder, higher-pressure zones near the seafloor, it dissolves into water between sediment grains. When conditions are right, the methane becomes less soluble in the cooling water and crystallizes into solid hydrate. Coarse-grained sediments favor hydrate formation because they offer more pore space for crystals to grow. The total amount of carbon stored in methane hydrates worldwide is enormous, though extracting it remains technically challenging.
The Timeline Spans Hundreds of Millions of Years
Most of the world’s coal formed during the Carboniferous period, specifically the Mississippian (359 to 323 million years ago) and Pennsylvanian (323 to 299 million years ago) sub-periods. This era saw uniquely favorable conditions: warm, humid climates, vast lowland swamps, and high atmospheric oxygen levels that supported massive plant growth. Importantly, the fungi and bacteria that are efficient at decomposing wood today had not yet fully evolved, so dead plant material accumulated faster than it could rot.
Oil and gas formation spans a broader timeline. Significant petroleum source rocks formed during several periods, from the Paleozoic Era (541 to 252 million years ago) through the Mesozoic, when warm, shallow seas covered large portions of the continents and supported massive plankton blooms. Some of the world’s largest oil reserves in the Middle East trace back to organic-rich sediments deposited during the Cretaceous period, around 100 million years ago. The transformation from buried organic matter to extractable fuel then took additional tens of millions of years as the sediments were buried deeper and heated.
What makes fossil fuels “fossil” is exactly this timeline. The carbon stored in coal, oil, and natural gas was pulled from the atmosphere by living organisms hundreds of millions of years ago. Burning these fuels releases that ancient carbon back into today’s atmosphere in a matter of decades, which is why fossil fuel combustion is the primary driver of rising carbon dioxide levels.

