Oil (or crude) is a liquid fuel kept in the sedimentary layers of the Earth. Both oil and gas have their origin in the algae and plankton remains that settled in calm, shallow waters (bays or a deltas) or deep waters. These remains, together with sand and slime, formed the sapropel, a dark mixture of bad smelling decaying organic matter. Little by little these sediments were covered by new ones which put great pressure and increased the temperature. These layers compacted till they formed the oil mother rock.
  The oil seldom stays in the mother rock because of its lower density. Sometimes it migrates to the surface, where a part evaporates and the rest form asphalts and bitumens. It can also be kept in porous rocks called oil traps.