Integrated numerical simulations and experimental investigations were employed to scrutinize the thermal, mechanical, and microstructural transformations of the AZ31 magnesium alloy during the friction stir welding (FSW) process. Especially, the primary focus was on the influence of process parameters such as rotational speed and welding speed on the temperature distribution, grain refinement, and mechanical properties of welded joints in alloys. By employing Deform-3D coupled with the integration of constitutive equations and dynamic recrystallization (DRX) models, the FSW process was investigated. The investigation revealed a significant increase in temperature when the tool's shoulder made contact with the weld, resulting in the substantial accumulation of heat during FSW. Distinctions became apparent between the advancing side (AS) and the receding side (RS), with the AS exhibiting slightly elevated levels of temperature, equivalent stress, strain, and grain size. Specifically, adjustments in the rotational speed of the stirring tool and a reduction in welding speed resulted in larger grain sizes within the alloy. For example, when the rotational speed was set at 1200 rpm and the travel rate was 200 mm/min, the initial grain size of the weld experienced a substantial decrease from 57.8 µm to 8.2 µm. Subsequent experimental verification, considering grain size and microhardness, was carried out to optimize FSW parameters for achieving the desired material properties. The accuracy of simulation results was validated through a meticulous comparison with experimental findings, underscoring the potential of numerical simulation in comprehending and predicting FSW processes.