A fundamental quest of modern astronomy is to locate the earliest galaxies and study how they influenced the intergalactic medium a few hundred million years after the Big Bang1-3. The abundance of star-forming galaxies is known to decline4,5 from redshifts of about 6 to 10, but a key question is the extent of star formation at even earlier times, corresponding to the period when the first galaxies might have emerged. Here we report spectroscopic observations of MACS1149-JD16, a gravitationally lensed galaxy observed when the Universe was less than four per cent of its present age. We detect an emission line of doubly ionized oxygen at a redshift of 9.1096 ± 0.0006, with an uncertainty of one standard deviation. This precisely determined redshift indicates that the red rest-frame optical colour arises from a dominant stellar component that formed about 250 million years after the Big Bang, corresponding to a redshift of about 15. Our results indicate that it may be possible to detect such early episodes of star formation in similar galaxies with future telescopes.