An electric motor with a motor shaft, a motor pinion and a sensor element for an optical rotary encoder which has at least one recess for the transmission of a light beam from the optical rotary encoder. The motor shaft, the motor pinion and the sensing element being integrally formed with one another and being coupled with the motor shaft in a rotationally fixed manner. Further, the sensor element has a drum-shaped design and is aligned coaxially with the motor pinion. The recess is formed in the sensor element in such a way that the light beam of the rotary encoder can pass radially relative to a rotational axis of the sensor element. The invention also relates to a medical device with such an electric motor.