Abstract The present study aims to investigate the effect of friction stir processing (FSP) conditions on the corrosion characteristic of AZ31B magnesium alloy. Specimens made of AZ31B alloy were friction stir processed under various processing conditions, and their microstructure and corrosion behavior were studied. The corrosion behavior was studied by potentiodynamic polarization, electrochemical impedance spectroscopy (EIS), and immersion test in 3.5% sodium chloride (NaCl) solution. The results showed a substantial improvement in the corrosion resistance of the friction stir processed AZ31B alloy. The improvement is likely a result of more stable corrosion products and microstructure refinement formed after friction sir processing.