The comparative study of the corrosion behaviour of the AZ31 magnesium alloy with different grain sizes immersed in simulated body fluids was made in chloride solutions (8g/L) and Phosphate Buffer-containing Solution (PBS). The influence of the immersion time was also analysed. Electrochemical techniques such as the open circuit potential, polarization curves, current transients and electrochemical impedance spectroscopy, complemented with scanning electron microscopy and energy dispersive spectroscopy were used. Immediately after the immersion in the corrosive media the corrosion resistance was similar for both grain sizes of the AZ31 alloy and higher in 2 NaCl solutions than in PBS. However, this corrosion behaviour was reversed after longer periods of immersion due to the stabilizing of the corrosion products of MgO and/or Mg(OH) 2 with P-containing compounds. These P-compounds contribute to a higher level of protection by hindering the aggressive action of chloride ions. The best corrosion behaviour of the AZ31 alloy was obtained for the finest grain alloy associated with the highest transfer resistance value, after long periods of immersion in PBS.