Finding massive galaxies that stopped forming stars in the early Universe presents an observational challenge because their rest-frame ultraviolet emission is negligible and they can only be reliably identified by extremely deep near-infrared surveys. These surveys have revealed the presence of massive, quiescent early-type galaxies appearing as early as redshift z ≈ 2, an epoch three billion years after the Big Bang. Their age and formation processes have now been explained by an improved generation of galaxy-formation models, in which they form rapidly at z ≈ 3-4, consistent with the typical masses and ages derived from their observations. Deeper surveys have reported evidence for populations of massive, quiescent galaxies at even higher redshifts and earlier times, using coarsely sampled photometry. However, these early, massive, quiescent galaxies are not predicted by the latest generation of theoretical models. Here we report the spectroscopic confirmation of one such galaxy at redshift z = 3.717, with a stellar mass of 1.7 × 10 11 solar masses. We derive its age to be nearly half the age of the Universe at this redshift and the absorption line spectrum shows no current star formation. These observations demonstrate that the galaxy must have formed the majority of its stars quickly, within the first billion years of cosmic history in a short, extreme starburst. This ancestral starburst appears similar to those being found by submillimetre-wavelength surveys. The early formation of such massive systems implies that our picture of early galaxy assembly requires substantial revision.