In recent years, many gamma-ray sources have been identified, yet the unresolved component hosts valuable information on the faintest emission. In order to extract it, a cross-correlation with gravitational tracers of matter in the Universe has been shown to be a promising tool. We report here the first identification of a cross-correlation signal between gamma rays and the distribution of mass in the Universe probed by weak gravitational lensing. We use the Dark Energy Survey Y1 weak lensing catalogue and the Fermi Large Area Telescope 9-year gamma-ray data, obtaining a signal-to-noise ratio of 5.3. The signal is mostly localised at small angular scales and high gamma-ray energies, with a hint of correlation at extended separation. Blazar emission is likely the origin of the small-scale effect. We investigate implications of the large-scale component in terms of astrophysical sources and particle dark matter emission.