Long-duration γ-ray bursts (GRBs) originate from ultra-relativistic jets launched from the collapsing cores of dying massive stars. They are characterized by an initial phase of bright and highly variable radiation in the kiloelectronvolt-to-megaelectronvolt band, which is probably produced within the jet and lasts from milliseconds to minutes, known as the prompt emission1,2. Subsequently, the interaction of the jet with the surrounding medium generates shock waves that are responsible for the afterglow emission, which lasts from days to months and occurs over a broad energy range from the radio to the gigaelectronvolt bands1,2,3,4,5,6. The afterglow emission is generally well explained as synchrotron radiation emitted by electrons accelerated by the external shock7,8,9. Recently, intense long-lasting emission between 0.2 and 1 teraelectronvolts was observed from GRB 190114C10,11. Here we report multi-frequency observations of GRB 190114C, and study the evolution in time of the GRB emission across 17 orders of magnitude in energy, from 5 × 10−6 to 1012 electronvolts. We find that the broadband spectral energy distribution is double-peaked, with the teraelectronvolt emission constituting a distinct spectral component with power comparable to the synchrotron component. This component is associated with the afterglow and is satisfactorily explained by inverse Compton up-scattering of synchrotron photons by high-energy electrons. We find that the conditions required to account for the observed teraelectronvolt component are typical for GRBs, supporting the possibility that inverse Compton emission is commonly produced in GRBs.