The interest in magnesium-based materials is promoted by their biocompatibility, their bioresorbability, and their recently discovered antibacterial potential. Until now, the widespread use of magnesium alloys in different corrosive environments was inhibited by their weakly controllable degradation rate and poorly understood microbiologically induced corrosion behavior. To better understand the degradation and usability of magnesium-based alloys, in this study we have fabricated superhydrophobic coatings on a magnesium-based alloy, and analyzed the behavior of this alloy in bacterial dispersions of Pseudomonas aeruginosa and Klebsiella pneumoniae cells in phosphate-buffered saline. It was shown that the immersion of such coatings in bacterial dispersions causes notable changes in the morphology of the samples, dependent on the bacterial dispersion composition and the type of bacterial strain. The interaction of the superhydrophobic coatings with the bacterial dispersion caused the formation of biofilms and sodium polyphosphate films, which provided enhanced barrier properties in magnesium dissolution and hence in dispersion medium alkalization, eventually leading to the inhibition of magnesium substrate degradation. The electrochemical data obtained for superhydrophobic samples in continuous contact with corrosive bacterial dispersions for 48 h indicated a high level of anticorrosion protection.