A lock for a firearm is disclosed. The firearm has a grip safety and a sear engageable to a biased hammer in a cocked position and releasable by a trigger. The lock includes a housing defining a bore within which a mainspring biasing the hammer is revived. A latch is rotatably mounted to the housing and has a grip safety arm and a cam follower, and has a first rotational excursion with the grip safety arm in engagement with and restricting the grip safety to block movement of the trigger, and an opposed second rotational excursion with the grip safety arm in disengagement from the grip safety to unblock depression of the grip safety and movement of the trigger. An actuator is mounted to the housing and cooperatively linked to the latch, and provides motive force for positioning the larch in the first rotational excursion and the second rotational excursion.