We present high-speed optical photometry of the soft gamma repeater SGR 0501+4516, obtained with ULTRACAM on two consecutive nights approximately 4 months after the source was discovered via its gamma-ray bursts. We detect SGR 0501+4516 at a magnitude of i = 24.4+/-0.1. We present the first measurement of optical pulsations from an SGR, deriving a period of 5.7622+/-0.0003 s, in excellent agreement with the X-ray spin period of the neutron star. We compare the morphologies of the optical pulse profile with the X-ray and infrared pulse profiles; we find that the optical, infrared and harder X-rays share similar double-peaked morphologies, but the softer X-rays exhibit only a single-peaked morphology, indicative of a different origin. The optical pulsations appear to be in phase with the X-ray pulsations and exhibit a root-mean-square pulsed fraction of 52+/-7%, approximately a factor of two greater than in the X-rays. Our results find a natural explanation within the context of the magnetar model for SGRs.