When microorganisms living in the sea die, they sink down to the bottom. As the time passes, these are covered by sand and clay. Over a period of million years, due to heat pressure and catalytic action, these remains are converted into hydrocarbons. These hydro-carbons rise through porous rocks till they are held up by some impermeable rocks and thus an oil trap in formed. To get petroleum, the impermeable rocks are drilled.