Long-duration gamma-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 kiloelectron volt-to-mega electronvoltband, which is probably produced within the jet and lasts from milliseconds to minutes, known as the prompt emission(1,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 bands(1-6). The afterglow emission is generally well explained as synchrotron radiation emitted by electrons accelerated by the external shock(7-9). Recently, intense long-lasting emission between 0.2 and 1 teraelectronvolts was observed from GRB 190114C(10,11). Here we report multifrequency observations of GRB 190114C, and study the evolution in time of the GRB emission across 17 orders of magnitude in energy, from 5 x 10(-6) to 10(12) 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.