  Ultra-high-energy cosmic rays (UHECRs) are atomic nuclei from space with
vastly higher energies than any other particles ever observed. Their origin and
chemical composition remain a mystery. As we show here, the large- and
intermediate-angular-scale anisotropies observed by the Pierre Auger
Observatory are a powerful tool for understanding the origin of UHECRs. Without
specifying any particular production mechanism, but only postulating that the
source distribution follows the matter distribution of the local Universe, a
good accounting of the magnitude, direction and energy dependence of the dipole
anisotropy at energies above $8 \times 10^{18}$ eV is obtained, after taking
into account the impact of energy losses during propagation (the "GZK
horizon"), diffusion in extragalactic magnetic field and deflections in the
Galactic magnetic field (GMF). This is a major step toward the long-standing
hope of using UHECR anisotropies to constrain UHECR composition and magnetic
fields. The observed dipole anisotropy is incompatible with a pure proton
composition in this scenario. With a more accurate treatment of energy losses,
it should be possible to further constrain the cosmic-ray composition and
properties of the extragalactic magnetic field, self-consistently improve the
GMF model, and potentially expose individual UHECR sources.
