  We have developed a model that explains cosmic rays with energies E between
\~0.3 PeV and the energy of the second knee at E_2 ~ 3*10^{17} eV as
originating from a recent Galactic gamma-ray burst (GRB) that occurred ~1 Myr
ago within 1 kpc from Earth. Relativistic shocks from GRBs are assumed to
inject power-law distributions of cosmic rays (CRs) to the highest energies.
Diffusive propagation of CRs from the local GRB explains the CR spectrum near
and above the first knee at E_1 ~ 3*10^{15} eV. The first and the second knees
are explained as being directly connected with the injection of plasma
turbulence in the interstellar medium on a ~1 pc and ~100 pc scales,
respectively. Transition to CRs from extragalactic GRBs occurs at E > E_2. The
origin of the ankle in the CR spectrum at E ~ 4*10^{18} eV is due to photopair
energy losses of UHECRs on cosmological timescales, as also suggested by
Berezinsky and collaborators. Any significant excess flux of extremely high
energy CRs deviating from the exponential cutoff behavior at E> E_{GZK} =
6*10^{19} eV would imply a significant contribution due to recent GRB activity
on timescales t < 10^8 yrs from local extragalactic sources within ~10 Mpc.

Astrophysics