The invention relates to a method and an apparatus for treating oily sludge. The method comprises the following steps: mixing of biochar produced by pyrolysis of oily sludge with the oily sludge, molding, pyrolysis treatment, and drying and oil desorption in the same hearth in order to achieve efficient integrated gradient utilization of energy. The apparatus comprises a screw conveying device, amixing device, a shaping device, a belt conveying device, a revolving cylinder indirect drying device, a revolving cylinder indirect thermal desorption device, the integrated heating furnace, gas burners and the like. The method and the apparatus have the advantages of small investment, quick effect, simple and flexible process, low running cost, high practicability, large treatment scale, complete harmlessness, high recycling rate, high energy utilization rate, full embodiment of the concepts of circular economy and low-carbon economy, and significant social, economic and environmental benefits.