Oily sludge is a kind of harmful solid waste produced by the petroleum industry. It is the key point of research to understand the mechanism of gas product changes during the pyrolysis process. This study combined density functional theory (DFT) calculation with a pyrolysis experiment to explore the changes in pyrolytic gas products from oily sludge. The results of thermogravimetric–mass spectrometry (TG–MS) and gas chromatography–mass spectrometry (GC–MS) showed that the gas products below 400°C were dominated by long‐chain hydrocarbons, but with the increase of the treatment temperature, the long‐chain hydrocarbons will decrease. The results of kinetics and thermodynamics showed that there were five stages of pyrolysis of oily sludge, and the values of E, ΔH, and ΔG were increased with the increase of pyrolysis temperature. The DFT calculation revealed that there were delocalized π‐electrons at the fracture‐prone sites, and the electrons on the functional groups of the molecule were more easily excited. The results can provide ideas for the pyrolysis mechanism of oily sludge and theoretical support for the optimization of the pyrolysis process.