The invention discloses an electronic mechanical brake with a parking function. The electronic mechanical brake comprises a parking braking mechanism and a service brake. The parking braking mechanism is used for achieving the parking function and comprises a torque motor, a spline, a tension spring, an electromagnetic push rod, a parking energy storage spring, a pin, a pin spring, a parking ball screw mechanism, a parking pressing rod, a parking push rod and the like. The service brake is used for completing service braking and comprises a speed reducing and torque increasing mechanism, a motion conversion mechanism, an automatic gap adjusting mechanism, a caliper body, a brake disc, a brake block, a brake friction plate and the like. The automatic gap adjusting mechanism is used for achieving automatic adjustment of the brake gap when the brake friction plate is abraded and comprises a transmission bolt, a two-jaw rotating wheel, a three-jaw rotating wheel, a chain wheel and a chain. The problems that an existing electronic mechanical brake is uniform in braking force distribution, low in braking reliability, slow in braking response and the like are solved, and the functions of automatic gap adjustment and parking braking can be achieved.