This paper provides a comprehensive derivation and application of the nonlocal Nernst-Planck-Poisson (NNPP) system for accurate modeling of electrochemical corrosion with a focus on the biodegradation of magnesium-based implant materials under physiological conditions. The NNPP system extends and generalizes the peridynamic bi-material corrosion model by considering the transport of multiple ionic species due to electromigration. As in the peridynamic corrosion model, the NNPP system naturally accounts for moving boundaries due to the electrochemical dissolution of solid metallic materials in a liquid electrolyte as part of the dissolution process. In addition, we use the concept of a diffusive corrosion layer, which serves as an interface for constitutive corrosion modeling and provides an accurate representation of the kinetics with respect to the corrosion system under consideration. Through the NNPP model, we propose a corrosion modeling approach that incorporates diffusion, electromigration and reaction conditions in a single nonlocal framework. The validity of the NNPP-based corrosion model is illustrated by numerical simulations, including a one-dimensional example of pencil electrode corrosion and a three-dimensional simulation of a Mg-10Gd alloy bone implant screw decomposing in simulated body fluid. The numerical simulations correctly reproduce the corrosion patterns in agreement with macroscopic experimental corrosion data. Using numerical models of corrosion based on the NNPP system, a nonlocal approach to corrosion analysis is proposed, which reduces the gap between experimental observations and computational predictions, particularly in the development of biodegradable implant materials.