An electromechanical locking device for a closing element or for a switching element having a stator and a rotor as components, wherein the rotor is mounted in the stator, and having a locking element, wherein the locking element is mounted in a first component of the components (10, 30), wherein the locking element can be moved between a first position and a second position, wherein in the first position the locking element engages in a second component (10, 30) of the components (10, 30), wherein in the second position the locking element is out of engagement with the second component (10, 30), wherein the second component (10, 30) has a first contact surface for the locking element, wherein the first contact surface moves the locking element from the first position to the second position when the rotor rotates; the second component (10, 30) has a second contact surface for the locking element, wherein the second contact surface leaves the locking element in the first position, wherein the second component (10, 30) comprises a component element, wherein the component element has the first contact surface and the component element is movably mounted in the remaining second component (10, 30), wherein the component element can be moved between a first position and a second position, wherein in the first position the first contact surface rests on the locking element in such a way that when the rotor rotates, the locking element is moved from the first position to the second position, wherein in the second position the locking element comes into contact with the second contact surface in such a way that the locking element remains in the first position, characterised in that the second component comprises at least one spring element, wherein the spring element pushes the component element into the first position, wherein the spring element is mounted in the second component. having a stator and a rotor as components, wherein the rotor is mounted in the stator, and having a locking element, wherein the locking element is mounted in a first component of the components (10, 30), wherein the locking element can be moved between a first position and a second position, wherein in the first position the locking element engages in a second component (10, 30) of the components (10, 30), wherein in the second position the locking element is out of engagement with the second component (10, 30), wherein the second component (10, 30) has a first contact surface for the locking element, wherein the first contact surface moves the locking element from the first position to the second position when the rotor rotates; the second component (10, 30) has a second contact surface for the locking element, wherein the second contact surface leaves the locking element in the first position, wherein the second component (10, 30) comprises a component element, wherein the component element has the first contact surface and the component element is movably mounted in the remaining second component (10, 30), wherein the component element can be moved between a first position and a second position, wherein in the first position the first contact surface rests on the locking element in such a way that when the rotor rotates, the locking element is moved from the first position to the second position, wherein in the second position the locking element comes into contact with the second contact surface in such a way that the locking element remains in the first position, characterised in that the second component comprises at least one spring element, wherein the spring element pushes the component element into the first position, wherein the spring element is mounted in the second component.