Petroleum forms from the remains of marine organisms that settle on ocean floors and get buried under sedimentary layers over millions of years. This process occurs only in sedimentary basins, making sedimentary rocks the primary source rocks for oil and gas. Metamorphic, plutonic, and volcanic rocks do not have the right conditions for petroleum formation.