Hydrogen can be used as an anti-cancer treatment. However, the continuous generation of H2 molecules within the tumor is challenging. Magnesium (Mg) and its alloys have been extensively used in the clinic as implantable metals. Here we develop, by decorating platinum on the surface of Mg rods, a Mg-based galvanic cell (MgG), which allows the continuous generation of H2 in an aqueous environment due to galvanic-cell-accelerated water etching of Mg. By implanting MgG rods into a tumor, H2 molecules can be generated within the tumor, which induces mitochondrial dysfunction and intracellular redox homeostasis destruction. Meanwhile, the Mg(OH)2 residue can neutralize the acidic tumor microenvironment (TME). Such MgG rods with the micro-galvanic cell structure enable hydrogen therapy to inhibit the growth of tumors, including murine tumor models, patient-derived xenografts (PDX), as well as VX2 tumors in rabbits. Our research suggests that the galvanic cells for hydrogen therapy based on implantable metals may be a safe and effective cancer treatment.