At redshift z = 2, when the Universe was just three billion years old, half of the most massive galaxies were extremely compact and had already exhausted their fuel for star formation(1-4). It is believed that they were formed in intense nuclear starbursts and that they ultimately grew into the most massive local elliptical galaxies seen today, through mergers with minor companions(5,6), but validating this picture requires higher-resolution observations of their centres than is currently possible. Magnification from gravitational lensing offers an opportunity to resolve the inner regions of galaxies(7). Here we report an analysis of the stellar populations and kinematics of a lensed z = 2.1478 compact galaxy, which surprisingly turns out to be a fast-spinning, rotationally supported disk galaxy. Its stars must have formed in a disk, rather than in a merger-driven nuclear starburst(8). The galaxy was probably fed by streams of cold gas, which were able to penetrate the hot halo gas until they were cut off by shock heating from the dark matter halo(9). This result confirms previous indirect indications(10-13) that the first galaxies to cease star formation must have gone through major changes not just in their structure, but also in their kinematics, to evolve into present-day elliptical galaxies.