An IMD may transition to an MRI mode automatically in response to detecting one or more conditions indicative of the presence of a strong magnetic field. Large static magnetic fields, such as those produced by an MRI device, may interact with the blood of a patient as it flows through the magnetic field to produce a voltage, a phenomenon referred to as the magnetohydrodynamic (MHD) effect. The voltage produced by the MHD effect is proportional to the strength of the magnetic field. As such, the voltage produced by blood flow in the strong magnetic field of an MRI device may result in a change in a characteristic of an electrogram (EGM). The IMD may detect the change in the characteristic of the EGM caused by the MHD effect and transition to operation in the MRI mode in response to at least the change in the EGM.