We report on the detection of a bright, short, structured X-ray burst coming from the supernova remnant RCW 103 on 2016 June 22 caught by the Swift /Burst Alert Telescope (BAT) monitor, and on the follow-up campaign made with Swift /X-ray Telescope, Swift /UV/Optical Telescope, and the optical/near-infrared (NIR) Gamma-Ray burst Optical and Near-infrared Detector. The characteristics of this flash, such as duration and spectral shape, are consistent with typical short bursts observed from soft gamma repeaters. The BAT error circle at 68 per cent confidence range encloses the point-like X-ray source at the centre of the nebula, 1E 161348–5055. Its nature has been long debated due to a periodicity of 6.67 h in X-rays, which could indicate either an extremely slow pulsating neutron star, or the orbital period of a very compact X-ray binary system. We found that 20 min before the BAT trigger, the soft X-ray emission of 1E 161348–5055 was a factor of ~100 higher than measured 2 yr earlier, indicating that an outburst had already started. By comparing the spectral and timing characteristics of the source in the 2 yr before the outburst and after the BAT event, we find that, besides a change in luminosity and spectral shape, also the 6.67 h pulsed profile has significantly changed with a clear phase shift with respect to its low-flux profile. The UV/optical/NIR observations did not reveal any counterpart at the position of 1E 161348–5055. Based on these findings, we associate the BAT burst with 1E 161348–5055, we classify it as a magnetar, and pinpoint the 6.67 h periodicity as the magnetar spin period.