Buoyant methane migrates upward through rock pores and fractures and either accumulates under impermeable layers or eventually reaches the surface and dissipates into the atmosphere. Because the methane generated in the subsurface is less dense than the rocks in which it is produced, it diffuses slowly upward through tiny, interconnected pore spaces and fractures, and it can eventually reach the Earth's surface and dissipate into the atmosphere. In places, however, the diffusion of methane is impeded by impermeable rock layers and gas can become trapped in structures. If enough gas accumulates under these impermeable layers, the structures can be drilled and gas can be extracted for use as an energy source.
Thermogenic methane is formed in a manner similar to oil.
As organic particles deposited in mud and other sediment become deeply buried and compressed, higher temperatures cause carbon bonds in organic compounds to break down and form oil with minor amounts of gas. The simultaneous formation of both oil and gas in the early stage of the thermal decomposition process is the principal reason for the association of oil and gas in accumulations present in the upper 2 to 3 km of the Earth's crust. In deep parts of basins and possibly even in subduction zones methane may be the only hydrocarbon formed. At greater burial depths, metamorphism may drive off all hydrogen atoms from organic compounds and leave a residue of carbon, often in the form of graphite. They form as either primordial gases that seep from our planet's interior or as gases liberated from crustal rocks during metamorphism.