The main drawback of conventional stenting procedure is the high risk of restenosis. The idea of a stent that "disappears" after having fulfilled its mission is very intriguing and fascinating. The stent mass should diminishing in time to allow the gradual transmission of the mechanical load to the surrounding tissues. Magnesium and its alloys seem to be among the most appealing materials to design biodegradable stents. The objective of this work is to develop, in a finite element (FE) framework, a model of magnesium degradation able to predict the corrosion rate and thus providing a valuable tool to design biodegradable stents. Continuum damage approach is suitable for modelling different damage mechanisms, including several types of corrosion. Corrosion is modelled by a scalar damage field which accounts for the material strength loss due to geometrical discontinuities. As damage progresses, the material stiffness decreases. Corrosion damage results as the superposition of stress corrosion process and uniform corrosion. The former describes the stress-mediated localization of the corrosion attack through a stress-dependent evolution law similar to the one used in analytical models, while the latter affects the free surface of the material exposed to an aggressive environment. The effects of both phenomena described are modelled through a linear composition of the two specific damage evolution laws. The model, developed in a FE framework, manages the mesh dependency, typical of strain-softening behaviour, including the FE characteristic length in the damage evolution law definition. The developed model is able to reproduce the behaviour of different magnesium alloys subjected to static and slow-strain-rate corrosion tests. Moreover, 3D stenting procedures accounting for the interaction with the arterial vessel are simulated.