An implantable medical device detects a strong static magnetic field associated with an MRI imaging instrument and operates in a safekeeping operating mode. The device includes an electronic circuit for the detection/stimulation of a cardiac activity, a weak field sensor detecting the presence of a first magnetic field of a permanent magnet being located in proximity to the device, a strong field sensor detecting the presence of a second magnetic field of an MRI imaging instrument during the course of an MRI examination.