Cosmic rays are thought to be produced in remnants of supernovae like SN 1987A, seen at the center of this Hubble Space Telescope image. The expanding shock waves of these stellar explosions can accelerate protons to near the speed of light.
NASA, ESA, R. Kirshner (Harvard-Smithsonian Center for Astrophysics and Gordon and Betty Moore Foundation), and M. Mutchler and R. Avila (STScI)