The anisotropic reflection and thermal re-emission of sunlight from an asteroid's surface acts as a propulsion engine. The net propulsion force (Yarkovsky effect) changes the orbital dynamics of the body at a rate that depends on its physical properties; for irregularly shaped bodies, the propulsion causes a net torque (the Yarkovsky-O'Keefe-Radzievskii-Paddack or YORP effect) that can change the object's rotation period and the direction of its rotation axis. The Yarkovsky effect has been observed directly, and there is also indirect evidence of its role in the orbital evolution of asteroids over long time intervals. So far, however, only indirect evidence exists for the YORP effect through the clustering of the directions of rotation axes in asteroid families. Here we report a change in the rotation rate of the asteroid 1862 Apollo, which is best explained by the YORP mechanism. The change is fairly large and clearly visible in photometric lightcurves, amounting to one extra rotation cycle in just 40 years even though Apollo's size is well over one kilometre. This confirms the prediction that the YORP effect plays a significant part in the dynamical evolution of asteroids.