Hydrogenases are nature's efficient catalysts for both the generation of energy via oxidation of molecular hydrogen and the production of hydrogen via the reduction of protons. However, their O2 sensitivity and deactivation at high potential limit their applications in practical devices, such as fuel cells. Here, we show that the integration of an O2-sensitive hydrogenase into a specifically designed viologen-based redox polymer protects the enzyme from O2 damage and high-potential deactivation. Electron transfer between the polymer-bound viologen moieties controls the potential applied to the active site of the hydrogenase and thus insulates the enzyme from excessive oxidative stress. Under catalytic turnover, electrons provided from the hydrogen oxidation reaction induce viologen-catalysed O2 reduction at the polymer surface, thus providing self-activated protection from O2. The advantages of this tandem protection are demonstrated using a single-compartment biofuel cell based on an O2-sensitive hydrogenase and H2/O2 mixed feed under anode-limiting conditions.