Friction stir welding has been extensively applied for the high-quality bonding of Mg alloys. The welding temperature caused by friction and plastic deformation is essential for determining the joint characteristics, especially the residual stress and weld microstructure. In this work, a modified moving heat source model was proposed by considering the variations in heat generation caused by friction shear stress at both the side and bottom surfaces of the tool. The application of this model was further extended to the entire welding process, especially in the plunging stage. The relative errors between the experimental and simulated peak temperatures at characteristic points were small, with a maximum of 10%, thereby validating the model for accurate temperature prediction. Furthermore, the influence of welding and rotational speed on temperature fields was systematically investigated. At relatively low welding and rotational speeds, the welding temperature increased significantly with either an increase in rotational speed or a decrease in welding speed. However, this effect gradually diminished at higher welding and rotational speeds. These results provide some valuable guidelines for controlling heat generation to improve the quality of Mg alloy welds.