Glitches have been frequently observed in neutron stars. Previously these glitches unexceptionally manifest as sudden spin-ups that can be explained as due to impulsive transfer of angular momentum from the interior superfluid component to the outer solid crust. Alternatively, such spin-up glitches may also be due to large-scale crust-cracking events. However, an unprecedented anti-glitch was recently reported for the magnetar 1E 2259+586. In this case, the magnetar clearly exhibited a sudden spin-down, strongly challenging previous glitch theories. Here we show that the anti-glitch can be well explained by the collision of a small solid body with the magnetar. The intruder has a mass of about $1.1 \times 10^{21}$ g. Its orbital angular momentum is assumed to be antiparallel to that of the spinning magnetar, so that the sudden spin-down can be naturally accounted for. The observed hard X-ray burst and decaying softer X-ray emission associated with the anti-glitch can also be reasonably explained. Our study indicates that a completely different type of glitches as due to collisions between small bodies and neutron stars should exist and may have already been observed previously. It also hints a new way for studying the capture events by neutron stars: through accurate timing observations of pulsars.