Biodegradable magnesium alloys have been developed as promising biomedical materials for temporary implants. To facilitate the implant design, it is essential to understand and quantify the corrosion behavior of magnesium alloys under mixed chemo-mechanical loadings. To this end, we proposed a multiphase-field model based on the variational principle to describe pitting corrosion and ductile fracture in biodegradable magnesium alloys. The multiphase-field model was calibrated and validated by our in vitro experiments with smooth and notched specimens of WE43 magnesium alloy. The experimental and computational results of the immersion tests and slow strain rate tensile-corrosion tests demonstrated that the proposed model can capture the corrosion, deformation and fracture behaviors of WE43 magnesium alloy.