An energetic γ-ray burst (GRB), GRB 211211A, was observed on 2021 December 11 by the Neil Gehrels Swift Observatory. Despite its long duration, typically associated with bursts produced by the collapse of massive stars, the discovery of an optical-infrared kilonova and a quasiperiodic oscillation during a gamma-ray precursor points to a compact object binary merger origin. The complete understanding of this nearby 1 Springer Nature 2021 LATEX template 2 GeV emission from a compact binary merger (∼ 1 billion light-years) burst will significantly impact our knowledge of GRB progenitors and the physical processes that lead to electromagnetic emission in compact binary mergers. Here, we report the discovery of a significant (> 5σ) transient-like emission in the highenergy γ-rays (HE; E> 0.1 GeV) observed by Fermi/LAT starting at 103 s after the burst. After an initial phase with a roughly constant flux (∼ 5 × 10−10 erg s−1 cm−2 ) lasting ∼ 2 × 104 s, the flux started decreasing and soon went undetected. The multi-wavelength ‘afterglow’ emission observed at such late times is usually in good agreement with synchrotron emission from a relativistic shock wave that arises as the GRB jet decelerates in the interstellar medium. However, our detailed modelling of a rich dataset comprising public and dedicated multiwavelength observations demonstrates that GeV emission from GRB 211211A is in excess with respect to the expectation of this scenario. We explore the possibility that the GeV excess is inverse Compton emission due to the interaction of a long-lived, low-power jet with an external source of photons. We discover that the kilonova emission can provide the necessary seed photons for GeV emission in binary neutron star mergers.