The performance of bioleaching technology was studied for the demulsification, oil content reduction and efficient removal of heavy metals from oily sludge. A method was established for treating oily sludge from an oil refinery. Firstly, bioleaching bacteria were enriched and acclimated. The effects of substrate type (FeSO4·7H2O and Na2S2O3·5H2O), concentration and aeration conditions on treatment performance were investigated, with response surface methodology used to optimize the treatment process. Finally, the effects of operating parameters on heavy metal removal under continuous flow conditions were investigated. Results show that an optimal treatment effect was achieved when 5.00 g/L FeSO4·7H2O and 5.64 g/L Na2S2O3·5H2O were used as substrates and the aeration ratio (air-water ratio) was 14.53 L/L. Under these conditions, the oily sludge reduction rate was 51.76 %, and the oil removal rate was 57.67 %. The removal rates for Pb, Hg and Cu ranged between 40 % and 70 %, with a stable total heavy metal reduction rate of 50 %. These results show that bioleaching technology is feasible for the treatment of oily sludge and heavy metal removal, with good potential for practical application.