- Two classes of rotating neutron stars-soft gamma-ray repeaters (SGRs) and anomalous X-ray pulsars-are magnetars, whose X-ray emission is powered by a very strong magnetic field (B approximately 10(15) G). SGRs occasionally become 'active', producing many short X-ray bursts. Extremely rarely, an SGR emits a giant flare with a total energy about a thousand times higher than in a typical burst. Here we report that SGR 1806-20 emitted a giant flare on 27 December 2004. The total (isotropic) flare energy is 2 x 10(46) erg, which is about a hundred times higher than the other two previously observed giant flares. The energy release probably occurred during a catastrophic reconfiguration of the neutron star's magnetic field. If the event had occurred at a larger distance, but within 40 megaparsecs, it would have resembled a short, hard gamma-ray burst, suggesting that flares from extragalactic SGRs may form a subclass of such bursts.