The explosion that results in a cosmic gamma-ray burst (GRB) is thought to produce emission from two physical processes -- the activity of the central engine gives rise to the high-energy emission of the burst through internal shocking and the subsequent interaction of the flow with the external environment produces long-wavelength afterglow. While afterglow observations continue to refine our understanding of GRB progenitors and relativistic shocks, gamma-ray observations alone have not yielded a clear picture of the origin of the prompt emission nor details of the central engine. Only one concurrent visible-light transient has been found and was associated with emission from an external shock. Here we report the discovery of infrared (IR) emission contemporaneous with a GRB, beginning 7.2 minutes after the onset of GRB 041219a. Our robotic telescope acquired 21 images during the active phase of the burst, yielding the earliest multi-colour observations of any long-wavelength emission associated with a GRB. Analysis of an initial IR pulse suggests an origin consistent with internal shocks. This opens a new possibility to study the central engine of GRBs with ground-based observations at long wavelengths.