  Magnetic reconnection is often invoked as a source of high-energy particles,
and in relativistic astrophysical systems it is regarded as a prime candidate
for powering fast and bright flares. We present a novel analytical model -
supported and benchmarked with large-scale three-dimensional particle-in-cell
simulations - that elucidates the physics governing the generation of power-law
energy spectra in relativistic reconnection. Particles with Lorentz factor
$\gamma\gtrsim 3\sigma$ (here, $\sigma$ is the magnetization) gain most of
their energy in the inflow region, while meandering between the two sides of
the reconnection layer. Their acceleration time is $t_{\rm acc}\sim \gamma
\,\eta_{\rm rec}^{-1}\omega_{\rm c}^{-1}\simeq 20\,\gamma\,\omega_{\rm
c}^{-1}$, where $\eta_{\rm rec}\simeq0.06$ is the inflow speed in units of the
speed of light and $\omega_{\rm c}=eB_0/mc$ is the gyrofrequency in the
upstream magnetic field. They leave the region of active energization after
$t_{\rm esc}$, when they get captured by one of the outflowing flux ropes of
reconnected plasma. We directly measure $t_{\rm esc}$ in our simulations and
find that $t_{\rm esc}\sim t_{\rm acc}$ for $\sigma\gtrsim {\rm few}$. This
leads to a universal (i.e., $\sigma$-independent) power-law spectrum $dN_{\rm
free}/d\gamma\propto \gamma^{-1}$ for the particles undergoing active
acceleration, and $dN/d\gamma\propto \gamma^{-2}$ for the overall particle
population. Our results help shedding light on the ubiquitous presence of
power-law particle and photon spectra in astrophysical non-thermal sources.
