The Al-RE intermetallic compounds formed by adding rare earth elements into AZ magnesium alloy have important effects on the microstructure and properties of alloy. Based on classical thermodynamic theory and Miedema model and Toop model, the heat of formation of compounds in Mg-Al-RE (Ce, Y, Gd) ternary alloy and Gibbs free energy of Al-RE (Al 4 Ce, Al 2 Y, and Al 2 Gd) compounds are calculated theoretically, the order of formation of compounds in alloys and the formation process of Al-RE compounds are analyzed. The results show that, Al-RE (Al 4 Ce, Al 2 Y, and Al 2 Gd) compounds are preferentially formed in Mg-Al-RE (Ce, Y, Gd) alloys, Al-RE compounds are mainly formed before the crystallization of α-Mg solid solution; meanwhile, with the crystallization of α-Mg solid solution, Al-RE compounds can still be formed sustainably. The order of Al-RE compounds formation ability is Al 4 Ce, Al 2 Gd, and Al 2 Y, but the order of formation ability is Al 2 Gd, Al 2 Y, and Al 4 Ce, when adding the same mass fraction of rare earth (Ce, Y, Gd). In as-cast structure of AZ91-0.9 wt%; RE (Ce, Y, Gd) experimental alloys, Al-RE compounds mainly distributes at grain boundaries of alloys at two different scales, and the amount of β-Mg 17 Al 12 phase in alloys decreases relative to that of alloys without RE.