We present high-speed, multicolour optical photometry of the anomalous X-ray pulsar 4U 0142+61, obtained with ULTRACAM on the 4.2-m William Herschel Telescope. We detect 4U 0142+61 at magnitudes of i′= 23.7 ± 0.1, g′= 27.2 ± 0.2 and u′ > 25.8, consistent with the magnitudes found recently by Hulleman et al. and hence confirming their discovery of both a spectral break in the optical and a lack of long-term optical variability. We also confirm the earlier discovery of Kern & Martin that 4U 0142+61 shows optical pulsations with an identical period (∼8.7 s) to the X-ray pulsations. The rms pulsed fraction in our data is 29 ± 8 per cent, 5–7 times greater than the 0.2–8 keV X-ray rms pulsed fraction. The optical and X-ray pulse profiles show similar morphologies and appear to be approximately in phase with each other, the former lagging the latter by only 0.04 ± 0.02 cycles. In conjunction with the constraints imposed by X-ray observations, the results presented here favour a magnetar interpretation for the anomalous X-ray pulsars.