A device and a method are disclosed for detecting electromagnetic fields, in particular, fields occurring in magnetic resonance tomography (MRT) or magnetic resonance imaging (MRI) tests. An implantable medical device (IMD), contained in a hermetically sealed housing, includes a control unit, a programming coil, and a communication unit, wherein the communication unit, together with the programming coil, is designed to allow communication between an external programming device and the IMD by utilizing alternating electromagnetic fields, and further comprising a detection unit for MRT interference fields, characterized in that the detection unit is designed in such a way that voltage profiles induced in the programming coil and originating from a pulsed alternating electromagnetic field of the MRT (gradient field) are detected, and a corresponding MRT detection signal is transmitted from the detection unit to the control unit, if communication with a programming device is not detected at the same time.