In friction stir welding (FSW) of dissimilar Al/Mg alloys, inevitable formation of intermetallic compounds (IMCs) has deleterious effect on the performance of joints. Although ultrasonic vibration enhanced FSW (UVeFSW) was invented to suppress the IMCs formation, the mitigating mechanism is not elucidated. In this work, the measured maximum temperature in weld nugget zone (WNZ) confirmed that in butt FSW of Al/Mg alloys the IMCs are generated by diffusion of solid atoms. The acoustic softening and antifriction effects were taken into account for computation of temperature, strain rate and dislocation density which are main factors affecting the inter-diffusion coefficients of Mg and Al atoms. An atom-diffusion based model was developed, and the formation and growth of the IMCs were quantitatively analyzed in FSW/UVeFSW of Al/Mg alloys. It was found that as the checking point flows toward to the tool, Al12Mg17 layer is first formed at the bonding interface, and then Al3Mg2 is formed at the Al side and grows rapidly. Under the conditions used in this study, the predicted values of IMCs thickness at the WNZ center in FSW and UVeFSW are 3.9 μm and 1.8 μm, respectively. The calculated IMCs thicknesses at the selected locations on the transverse cross- and horizontal cross- agree well with the measured ones. Ultrasonic induced dislocation-annihilation and associated decreasing of dislocation density in UVeFSW cause declining of the atomic diffusion coefficients, so that the formation and growth of IMCs are inhibited with ultrasonic action.