Magnetars are slowly-rotating neutron stars with extremely strong magnetic fields 1013-15 G, episodically emitting 100 ms long X-ray bursts with energies of 1040-41 erg. Rarely, they produce extremely bright, energetic giant flares that begin with a short (0.2 s), intense flash, followed by fainter, longer lasting emission modulated by the magnetar spin period (typically 2-12s), thus confirming their origin. Over the last 40 years, only three such flares have been observed in our local group, which all suffered from instrumental saturation due to their extreme intensity. It has been proposed that extra-galactic giant flares likely constitute a subset of short gamma-ray bursts, noting that the sensitivity of current instrumentation prevents us from detecting the pulsating tail, while the initial bright flash is readily observable out to distances 10-20 Mpc. Here, we report X- and gamma-ray observations of GRB 200415A, which exhibits a rapid onset, very fast time variability, flat spectra and significant sub-millisecond spectral evolution. These attributes match well with those expected for a giant flare from an extra-galactic magnetar, noting that GRB 200415A is directionally associated with the galaxy NGC 253 (3.5 Mpc away). The detection of 3 MeV photons provides definitive evidence for relativistic motion of the emitting plasma. The observed rapid spectral evolution can naturally be generated by radiation emanating from such rapidly-moving gas in a rotating magnetar.