To predict the grain size and microstructure evolution during friction stir welding (FSW) of AZ91 magnesium alloy, a finite element model (FEM) is developed based on the combination of a cellular automaton model and the Kocks − Mecking and Laasraoui–Jonas models. First, according to the flow stress curves and using the Kocks − Mecking model, the hardening and recovery parameters and the strain rate sensitivity were calculated. Next, an FEM model was established in Deform-3D software to simulate the FSW of AZ91 magnesium alloy. The results of the FEM model are used in microstructure evolution models to predict the grain size and microstructure of the weld zone. There is a good agreement between the simulated and experimental microstructures, and the proposed model can simulate the dynamic recrystallization (DRX) process during FSW of AZ91 alloy. Moreover, microstructural properties of different points in the SZ as well as the effect of the w/v parameter on the grain size and microstructure are considered.