a locking mechanism for hydraulically actuated devices is disclosed herein . the mechanism includes a slotted lock shaft coaxially mounted with respect to a piston assembly , the piston assembly being disposed in a hydraulic cylinder . the lock shaft has end faces or shoulders which engage a portion of a shaft associated with the piston assembly to lock the piston assembly and the ram shaft in a predetermined position . the lock shaft has a configured surface which cooperates with a configured surface of the piston assembly for unlocking the mechanism . the locking mechanism is described for use with a ram type blowout preventer but can be used with various types of hydraulically actuated devices .