Recently, some researchers have simulated FSW using FEM and studied the influence of process parameters and tool geometry on material flow, welding force, and temperature and strain distributions during friction stir processing. Additionally, in terms of microstructure modeling, various approaches such as the Cellular Automaton (CA) model have been developed to simulate microstructural evolution during plastic deformation processes. In this work, a finite element model (FEM) is established to study the microstructure evolution during friction stir welding (FSW) of AZ91 magnesium alloy. To this aim, first, the hot compression tests at different temperatures and strain rates were carried out to achieve the flow stress curves. Then, the hardening parameter, the recovery parameter and the strain rate sensitivity were calculated according to flow stress results and using the Kocks−Mecking model. Next, a continuum based thermo-mechanically coupled rigid-viscoplastic FEM model was proposed in Deform-3D software to simulate the FSW of AZ91 magnesium alloy. To evaluate microstructure of the weld zone a model is proposed based on the combination of Cellular Automaton and Laasraoui-Jonas models. Temperature history, strain distribution and welding force are achieved through thermomechanical model and microstructure and grain size distribution are achieved by microstructure evolution model. The effects of rotational and traverse speeds on the grain size and microstructure of weld zone are considered. There is a good agreement between results of numerical models and experiments in the aspects of welding forces, temperature history and grain size. Additionally, the proposed microstructure evolution model can simulate accurately the dynamic recrystallization (DRX) process during FSW and its resulted microstructure.