We present observations of the early X-ray emission for a sample of 40 gamma-ray bursts (GRBs) obtained using the Swift satellite for which the narrow-field instruments were pointed at the burst within 10 minutes of the trigger. Using data from the Burst Alert and X-Ray Telescopes, we show that the X-ray light curve can be well described by an exponential that relaxes into a power law, often with flares superimposed. The transition time between the exponential and the power law provides a physically defined timescale for the burst duration. In most bursts the power law breaks to a shallower decay within the first hour, and a late emission hump is observed which can last for many hours. In other GRBs the hump is weak or absent. The observed variety in the shape of the early X-ray light curve can be explained as a combination of three components: prompt emission from the central engine; afterglow; and the late hump. In this scenario, afterglow emission begins during or soon after the burst and the observed shape of the X-ray light curve depends on the relative strengths of the emission due to the central engine and that of the afterglow. There is a strong correlation such that those GRBs with stronger afterglow components have brighter early optical emission. The late emission hump can have a total fluence equivalent to that of the prompt phase. GRBs with the strongest late humps have weak or no X-ray flares.