Recent studies of galaxies approximately 2-3 Gyr after the Big Bang have revealed large, rotating disks, similar to those of galaxies today. The existence of well-ordered rotation in galaxies during this peak epoch of cosmic star formation indicates that gas accretion is likely to be the dominant mode by which galaxies grow, because major mergers of galaxies would completely disrupt the observed velocity fields. But poor spatial resolution and sensitivity have hampered this interpretation; such studies have been limited to the largest and most luminous galaxies, which may have fundamentally different modes of assembly from those of more typical galaxies (which are thought to grow into the spheroidal components at the centres of galaxies similar to the Milky Way). Here we report observations of a typical star-forming galaxy at z = 3.07, with a linear resolution of approximately 100 parsecs. We find a well-ordered compact source in which molecular gas is being converted efficiently into stars, likely to be assembling a spheroidal bulge similar to those seen in spiral galaxies at the present day. The presence of undisrupted rotation may indicate that galaxies such as the Milky Way gain much of their mass by accretion rather than major mergers.