Vivianite, a hydrous ferrous iron-phosphate mineral (Fe3(PO4)2<middle dot>8H2O), readily oxidizes in contact with air, yielding the less hydrous mixed-valent mineral metavivianite. This topotactic transformation nominally occurs by oxidative dehydrogenation, in which outgoing electrons from the iron sublattice are charge-compensated by hydrolysis of structural water. However, the details of this internal charge balancing mechanism that allows the structure to remain electrostatically stable remain unknown. Here, we use density functional theory calculations and ab initio thermodynamics to evaluate the energetics of this process in terms of hydrogen release as a function of environmental variables, such as water or hydrogen partial pressures and temperature. The results show a thermodynamic driving force for vivianite phase transformation as oxidation progresses, which is triggered by its rigid structure that has limited accommodation for hydrogen vacancies. In contrast, metavivianite has a more flexible lattice and hydrogen bond network that stabilizes these hydrogen defects. Metavivianite is shown to be a stable intermediate for 66% residual Fe2+ down to 33% Fe2+, below which other phases/structures, such as santabarbarite, should be more thermodynamically favorable. Our study provides a basis for experimental tests of our mechanistic findings and helps fill a basic knowledge gap about the solid-state process that defines how vivianite interacts with its surrounding environment.