An active implantable medical device comprising circuits for right ventricular, left ventricular, right atrial and eventually left atrial detection, as well as circuits for right and left ventricular stimulation. The device can operate in mode of resynchronization of the ventricular contractions, with an adjustable delay of inter-ventricular stimulation. It includes moreover: circuits for atrial stimulation; circuits able to operate the device in AAI mode with right atrial stimulation and right ventricular detection; circuits for detection of ventricular capture, to determine the detection or the loss of capture after a right ventricular stimulation and a left ventricular stimulation; and of the circuits for mode switching, able to control a switching of mode, from the mode of resynchronization towards AAI mode, in response to the detection of a loss of capture after a right ventricular stimulation or a left ventricular stimulation.