Melting treatment has emerged as a promising technology for managing municipal solid waste incineration (MSWI) fly ash owing to its advantageous features of effective detoxification and volume reduction. The melting treatment of MSWI fly ash involves the immobilization of heavy metals by crystals and liquid phase. Herein, the immobilization mechanism of heavy metals (Cu, Pb and Cd) by the crystals and the liquid phase was investigated using melting experiments, thermodynamic calculations and density functional theory (DFT) calculations. Results demonstrate that the immobilization of heavy metals is influenced by a combination of factors: the reaction of heavy metals, physical encapsulation ability of the liquid phase and chemical fixation ability of both the crystals and the liquid phase. An increase in the content of SiO2 and Al2O3 promotes the conversion of heavy metals oxides into heavy metals chlorides. Furthermore, an increase in the content and polymerization degree of the liquid phase facilitates the physical encapsulation of heavy metals chlorides. The chemical fixation ability of the crystals and the liquid phase differs for Cu and Pb, while Cd cannot be immobilized through chemical fixation. To enhance the immobilization of heavy metals during melting treatment, the chemical composition of MSWI fly ash should be adjusted within the anorthite region of the ternary phase diagram. This study provides valuable insights into the immobilization mechanism of heavy metals by the crystals and the liquid phase during the melting treatment of MSWI fly ash.