A general approach to calculate the diabatic surfaces for electron-transfer reactions is presented, based on first-principles molecular dynamics of the active centers and their surrounding medium. The excitation energy corresponding to the transfer of an electron at any given ionic configuration (the Marcus energy gap) is accurately assessed within ground-state density-functional theory via a novel penalty functional for oxidation-reduction reactions that appropriately acts on the electronic degrees of freedom alone. The self-interaction error intrinsic to common exchange-correlation functionals is also corrected by the same penalty functional. The diabatic free-energy surfaces are then constructed from umbrella sampling on large ensembles of configurations. As a paradigmatic case study, the self-exchange reaction between ferrous and ferric ions in water is studied in detail.A wide variety of processes and reactions in electrochemistry, molecular electronics, and biochemistry have a common denominator: they involve a diabatic electron transfer process from a donor to an acceptor [1]. These reactions cover processes and applications as diverse as solar-energy conversion in the early steps of photosynthesis, oxidation-reduction reactions between a metallic electrode and solvated ions, and the I-V characteristics of molecular-electronics devices [2]. The key quantities of interest are the reaction rates (or, equivalently, the conductance) and the reaction pathways. Reaction rates, in the general scenario of Marcus theory [3,4,5], have a thermodynamic contribution (the classical Franck-Condon factor, broadly related to the free energy cost of a nuclear fluctuation that makes the donor and the acceptor levels degenerate in energy), and an electronic-structure, tunneling contribution (the LandauZener term, related to the overlap of the initial and final states).We argue in the following that state-of-the-art firstprinciples molecular dynamics calculations, together with several algorithmic and conceptual advances, are able to describe with quantitative accuracy these diabatic processes, while including the realistic description of the complex environment encountered, e.g. in nanoscale devices or at the interface between molecules and metals. Fig. 1 shows schematically an electron-transfer process and the free-energy diabatic surfaces according to the picture that was pioneered by Marcus [3,4,6,7]. In a polar solvent, the electron transfer process is mediated by thermal fluctuations of the solvent molecules. In the reactant state, the transferring electron is trapped at the donor site by solvent polarization; transfer might occur when the electron donor and acceptor sites become degenerate due to the thermal fluctuations of the solvent molecules. To characterize the role of the solvent on the electron-transfer reaction, a reaction coordinate ǫ for a given ionic configuration is introduced, as the energy dif- ference between the product and reactant state at that configuration [8]. This definition of reaction coordinate...