Oily sludge is both a hazardous waste and a resource that contains significant amounts of recoverable mineral oil, while the recovery and reduction of mineral oil are the main methods of reducing the hazardous characteristics of oily sludge. In this study, chemical hot washing was used to treat oily sludge from an oilfield in Xinjiang, China, and the optimum detergent formulation and optimal process parameters were obtained through chemical compounding and process parameter optimization. The mechanism of oil removal was explored through a variety of different components of crude oil. The results show that the compound detergent AXQ (sodium phosphate/ sodium carbonate = 4:6) can reduce the oil content of oily sludge from 20.13 to 1.55% at a dosing rate of 1.5%, 70 °C, a solid−liquid ratio of 1:5, a stirring rate of 400 rpm, a stirring time of 20 min, a pH value of 9, a centrifugal speed of 3000 rpm, a centrifugal time of 10 min, and an oil removal rate of 92.30%, meeting the DB 65/T 3998-2017 treatment standard. Chemical thermal washing removed most of the mineral oil, with 93.47, 95.38, 63.35, and 79.47% removal of the four components, respectively, and gas chromatography analysis indicated that most of the low carbon number petroleum hydrocarbons prior to n-heptadecane were removed. Analysis of the different crude oil components after hot washing shows that the alkaline inorganic salts destroy the stable emulsion system formed by naturally occurring interfacially active substances like asphaltene and resin through electrical neutralization, achieving a three-phase separation of oil, water, and solids and laying the foundation for mineral oil removal.