A generator for an implantable cardiac prosthesis, having a safekeeping mode of operation during an exposure to a magnetic field. The generator is connected to a lead including a first conductor (18) connected to a distal electrode (14), and a second conductor (20) connected to a proximal electrode (16). The generator to which the lead is connected includes a switch that temporarily switches to the potential of the metal housing of the generator (i.e., the ground potential) a first terminal connection (26) coupled to the external conductor (20) of the lead, and connects to the electronic circuit of detection/stimulation a second terminal connection (24) coupled to the internal conductor (18) of the lead. The first conductor temporarily acts as a shield for the second conductor for the duration of an MRI examination ensuring protection against the deleterious effects of exposure of the lead to the magnetic field generated by the MRI apparatus, notably heating of the electrodes due to induced currents in the conductors.