In the past decade, our understanding of how stars and galaxies formed during the first 5 billion years after the Big Bang has been revolutionized by observations that leverage gravitational lensing by intervening masses, which act as natural cosmic telescopes to magnify background sources. Previous studies have harnessed this effect to probe the distant Universe at ultraviolet, optical, infrared and millimetre wavelengths1-6. However, strong-lensing studies of young, star-forming galaxies have never extended into X-ray wavelengths, which uniquely trace high-energy phenomena. Here, we report an X-ray detection of star formation in a highly magnified, strongly lensed galaxy. This lensed galaxy, seen during the first third of the history of the Universe, is a low-mass, low-metallicity starburst with elevated X-ray emission, and is a likely analogue to the first generation of galaxies. Our measurements yield insight into the role that X-ray emission from stellar populations in the first generation of galaxies may play in reionizing the Universe. This observation paves the way for future strong-lensing-assisted X-ray studies of distant galaxies reaching orders of magnitude below the detection limits of current deep fields, and previews the depths that will be attainable with future X-ray observatories.