IT is widely accepted that natural gas is formed from thermal decomposition of both oil in reservoirs and, to a lesser extent, the organic matter in shales from which the oil was derived1-6. But laboratory pyrolysis experiments on shales do not reproduce the methane-rich composition typical of most gas reservoirs7, leading to suggestions7 that other mechanisms, such as transition-metal catalysis, may be important. The discrepancy might, however, instead arise because gas (and oil) deposits have migrated from their source rocks, so that the reservoir composition might not be representative of the composition in the source rocks where the hydrocarbons were generated. To address this question, we have analysed gas samples coproduced with oils directly from a source rock (the Bakken shales, North Dakota, USA) where the local geology has prevented significant hydrocarbon migration. The methane contents of these Bakken-shale gases are much lower than that of conventional gas reservoirs, but are consistent with that from pyrolysis experiments8,9 on these shales. Thus, because these Bakken gases form with (rather than from) oils, we argue that compositional differences between gases from source rocks and conventional gas deposits result from fractionation processes occurring after hydrocarbon expulsion from the source rock.