A surgical instrument for performing endoscopic surgical procedures. In one embodiment, the instrument includes a knife that remains unexposed until initiation of a cutting sequence, and returns to an unexposed position at the conclusion of the cutting sequence, minimizing the risk of injury to the person handling the instrument. In another embodiment, the instrument includes a flexible neck for articulating a surgical head assembly with respect to the shaft of the instrument. In another embodiment, a device for locking the articulated head at an angle of articulation is provided. In yet another embodiment, a mechanism for opening and closing an anvil assembly is disclosed.