The Early Days of Oil
First, tiny planktonic plants (floating plants) die and sink to the sea bed. They are buried in mud. Over millions of years they turn into rock. The organic remains form specks of carbon-rich kerogen. Later this turns to oil. The oil moves through porous sedimentary rock until its path is blocked by a non-porous rock (called a "cap rock"). The oil cannot move further. It remains there in the pores of the porous rock, like water in a sponge, waiting for discovery. Once found, the rock covering the oil has to be drilled through to reach the reservoir of oil.
Oil and natural gas are also called petroleum.