The invention provides an electromagnetic actuator used for gear shifting of an electric automobile. The electromagnetic actuator comprises a shifting fork, an iron piece, a base, a tubular shell mounted on the base, side end covers for fixedly plugging the two ends of the shell, an iron core, and coils for sleeving the two ends of the iron core in a spaced mode; the coils are fixedly connected with the shell, two windows are formed in the side wall of the shell, and three notched optocouplers are fixedly arranged in one window in the axial direction and correspond to the first gear, the neutral gear and the second gear of the automobile; the shifting fork perpendicularly and fixedly penetrates through the iron core, one end of the shifting fork is fixedly connected with the iron piece, the other end of the shifting fork penetrates out of a gap of the other window, and the other end of the iron piece penetrates into a notch in one notched optocoupler in a spaced mode; and an electric control module comprises a single chip microcomputer, a relay, an audion, a diode and a switch, wherein the three PWM output ends of the single chip microcomputer are connected with the input ends of the first gear optocoupler, the second gear optocoupler and the neutral gear optocoupler correspondingly. The coils are controlled to be on or off by controlling the corresponding optocouplers to be on or off, electromagnetic force generated when the coils are electrified drives the shifting fork to move, and gear shifting is smoothly completed.