Oil comes from the remains of tiny plants and animals (plankton) that died in ancient seas between 10 million and 600 million years ago. After the organisms died, they sank into the sand and mud at the bottom of the sea.
Over the years, the organisms decayed in the sedimentary layers. In these layers, there was little or no oxygen present. So microorganisms broke the remains into carbon-rich compounds that formed organic layers. The organic material mixed with the sediments, forming fine-grained shale, or source rock. As new sedimentary layers were deposited, they exerted intense pressure and heat on the source rock. The heat and pressure distilled the organic material into crude oil and natural gas. The oil flowed from the source rock and accumulated in thicker, more porous limestone or sandstone, called reservoir rock. Movements in the Earth trapped the oil and natural gas in the reservoir rocks between layers of impermeable rock, or cap rock, such as granite or marble.
These movements of the Earth include:
Folding - Horizontal movements press inward and move the rock layers upward into a fold or anticline.
Faulting - The layers of rock crack, and one side shifts upward or downward.
Pinching out - A layer of impermeable rock is squeezed upward into the reservoir rock.